Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i insert e-mail addresses into an existing Outlook message?

Status
Not open for further replies.

marcdoyle

Technical User
Dec 18, 2002
95
GB
I've created an outlook e-mail using olcreatitem, and put addresses into it using the .to .cc and .bcc variables, but i cant work out how to add new addresses to the list after the e-mail has been created. The code i've used is:

Private Sub createmail()
On Error GoTo continue
MESSAGE.To = MESSAGE.To + tovar
MESSAGE.CC = MESSAGE.CC + ccvar
MESSAGE.BCC = MESSAGE.BCC + bccvar
MESSAGE.Display

Set MESSAGE = Nothing
Set OUTAPP = Nothing
Exit Sub

continue:
createnewmail
End Sub

Private Sub createnewmail()
Err.Clear
Set MESSAGE = OUTAPP.CreateItem(olMailItem)
createmail
End Sub

I thought that by not setting the variable initially, and waiting for an error to occur (the error being that the email hasnt been created) that if the email "MESSAGE" already existed, that outlook would re-use it rather than creating a new instance, but it doesnt seem to work. OUTAPP and MESSAGE are both defined as public variables in the declarations section.

Someone please help!!

Thanks
 
Dim objOlApp As Outlook.Application
Dim objOlItem As Outlook.MailItem

Set objOlApp = New Outlook.Application
Set objOlItem = objOlApp.CreateItem(olMailItem)

With objOlItem
.Recipients.Add "Someone@domain.com"
.Subject = "Test"
.Send
End With

Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
thanks for trying, but i'm afraid that's the basic tutorial version of the code which doesnt allow for what my post was asking for. I did find out the problem though, and it was the fact that i had "MESSAGE = NOTHING" in there which was basically making my program forget that the session already exists! D'oh!
 
Sorry, didn't read your post properly! I'll try and pay attention in future.


Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top