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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open email from vb app 1

Status
Not open for further replies.

MissouriTiger

Programmer
Oct 10, 2000
185
US
How can I open Outlook or Outlook Express to send email to an address selected by user? If the explanation is too lengthy, is there a website or other resource with detailed explanation? I have consulted nearly a dozen books. I also posted this question 2 days ago, but it has vanished. Please help if you can.
 
Dim objOutLook As Outlook.Application
Dim objMailItem As MailItem

Set objOutLook = New Outlook.Application
Set objMailItem = objOutLook.CreateItem(olMailItem)

'then you can use the properties of the mail item, like

objMailItem.Subject = "Subject of the e mail"
objMailItem.Body = "Line 1" & vbCR & "Line2"

'then you can use the Recipients collection to add recipients, or you can use the To property:

' EITHER
objMailItem.Recipients.Add "me@domain.com"
objMailItem.Recipients.Add "you@domain.com"
' OR
objMailItem.To = "me@domain.com; you@domain.com"

When you are ready to send the e mail, just invoke the Send method:

objMailItem.Send

NOTE: to use the above, you have to set a reference to Microsoft Outlook X Object Library (X = 9 if you have Office2000 installed).

Simon
 
Thanks for the help. I'm very grateful. I actually found another way on the web a short while ago. I'll post it. However, I also can use your code, since you have tipped me off to a way to improve my app. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top