Help creating outlook email message using vb

L

lanem

I need to create an addin using vb or vb.net that will create an email
message in outlook and save it to the drafts folder. Anyone have any
direction for me to get started or know of any good documentation for
something like this online? Thanks.
 
K

Ken Slovak - [MVP - Outlook]

www.outlookcode.com is the place to start and another is the Object Browser
and its Help for the Outlook object model.

In the simplest terms the code would look like this, ignoring all the
initializations you need for an Outlook COM addin:

Dim oMail As Outlook.MailItem
Set oMail = oApp.CreateItem(olMailItem)
oMail.Subject = "Test"
oMail.Body = "This is a test"
oMail.Save

That will save the item to the Drafts folder.

You also should look at the Resources page at www.microeye.com. There is
information from that page for VS.NET addins and a link to download the
ItemsCB COM addin template which shows best practices using VB 6 for Outlook
COM addins.
 
L

lanem

What is "olMailItem" in CreateItem(olMailItem)?

I hope this isn't too dumb of a question. I just don't know what that value
is?

Thanks.
 
K

Ken Slovak - [MVP - Outlook]

It's an enumerated value that tells Outlook to create a mail item. It's part
of the OlItemType enumeration. It's listed in the Object Browser. That tool
is invaluable when you want to see anything about the Outlook object model.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top