How do I create a New Mail Item from DB

Add-in Express™ Support Service
That's what is more important than anything else

How do I create a New Mail Item from DB
I am trying to create a mail message 
Chris Boothman




Posts: 3
Joined: 2006-04-16
I'm probably being thick but am using VB.NET and have successfully read some information from a database and now need to create a New Mailitem to appear in the Inbox with that information in the email.

I am struggling with the "olMailItem" not declared message.

Dim myItem = OutlookApp.CreateItem(olMailItem)


All help gratefully received!
CjB
Hawkriver Group
Posted 16 Apr, 2006 08:22:26 Top
Sergey Grischenko


Add-in Express team


Posts: 7230
Joined: 2004-07-05
Hi Chris.

Try the code below:

Dim mail As Outlook.MailItem

mail = OutlookApp().CreateItem(Outlook.OlItemType.olMailItem)
mail.To = "test@company.com"
mail.Subject = "My Subject"
mail.Save()
Posted 17 Apr, 2006 07:56:58 Top
Chris Boothman




Posts: 3
Joined: 2006-04-16
Thanks Sergey,

That works well but seems to put the email into the "Drafts" folder. Can I specify for it to go into the "Inbox"?

Chris
CjB
Hawkriver Group
Posted 17 Apr, 2006 13:05:39 Top
Sergey Grischenko


Add-in Express team


Posts: 7230
Joined: 2004-07-05
Hi Chris.

Actually all new mail items are created in the Drafts folder. The Inbox folder is used for incoming messages. Why do you want to put a new message into the Inbox folder?
Anyway, to move an item from one folder to another you can use the Move method of the Outlook.MailItem inteface.


Posted 18 Apr, 2006 05:09:39 Top