Click to See Complete Forum and Search --> : VB Emailing
rlong
August 9th, 2001, 04:22 PM
Hello. I am wondering how to go about emailing a long message in VB. I am using Outlook.application and such to do the actual mailing which works fine. But how do i go about sending a long message(30 lines long)? When I continue typing my message on the next line, it thinks it is more code. Do I use a '+' or '()'? None of those seem to work. I also must include contents of string variables in this message. I am sure this is easy, but I can't figure it out!! Please help!
enigmaos
August 9th, 2001, 06:06 PM
well, you can either use CDO library or MAPISession/MAPIMessage components. I have done some email functions in VB 6 with both of them (with Outlook and POP3/SMTP), but personally, I like CDO more than MAPI. I believe you can have more than 30 lines in a message.
Is MultiLine turned on for the textbox?
enigmaos@yahoo.com
rlong
August 9th, 2001, 06:25 PM
I am not sure what you mean by multiline. where can i turn it on? The problem is this:
this is a test
message
"message" will be looked at by VB as another line of code separate from the line before it. How do I make it so that it will take roughly 30 lines of text and treat it as one line?
enigmaos
August 9th, 2001, 06:37 PM
do you have the code? I can take a look at the code.
enigmaos@yahoo.com
enigmaos
August 9th, 2001, 07:57 PM
here's an exmaple (no need to add CDO library and no MAPI components), but Outlook has to be open. you can just copy and paste the code into a Command button.
dim strRecipient as string
dim strMessage as string
dim strSubject as string
dim i as integer
strRecipient = "Joe Smith" ' someone in your address book
strSubject = "This is a test"
'Create 32 lines of text
for i = 0 to 32
strMessage = strMessage & "This is line " & i & vblf
next i
'Create MAPI Session
set objsession = CreateObject("MAPI.session")
'logon to exchange server with default username
objsession.logon "", "", false, false, 0
'create message and recipient objects
set objNewMessage = objsession.Outbox.Messages.Add
set objRecipient = objNewMessage.Recipients.Add
'pass names, subject and message to the objects
objRecipient.Name = strRecipient
objNewMessage.Subject = strSubject
objNewMessage.Text = strMessage
objRecipient.Resolve
objNewMessage.Update
objNewMessage.Send
objsession.logoff
try that.
shree
August 9th, 2001, 08:10 PM
Underscore is the line continuation character. Make sure that there is a space before the underscore and the last character on the line.
strMessage = strMessage & "This is line " & i & vblf & _
"This is another line" & _
"This is still on the second line"
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.