email sent fron VB Com Addin with empty .body

E

Epelman

I've a macro that send a draft email to a distribution list. It works ok.
Now I'm trying to do the same with a Visual Studio @008 Vb Com Addin.
The problem is that the email is sent with null .body ...
I d'nt know where is my error.

Please see the code - will appreciate any help

Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup
MyForwardSend()
End Sub

Private Sub MyForwardSend()
Dim myApp As Outlook.Application
Dim myFolderDrafts As Outlook.MAPIFolder
Dim myForward As Outlook.MailItem
Dim myMail As Object 'Outlook.MailItem
Dim myNameSpace As Outlook.NameSpace
Dim myRecipient As Outlook.Recipient

myApp = CreateObject("Outlook.Application")
myNameSpace = myApp.GetNamespace("MAPI")
myFolderDrafts =
myNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderDrafts)

myMail = myFolderDrafts.Items.Item(myFolderDrafts.Items.Count)
myForward = myMail.Forward

myRecipient = myForward.Recipients.Add("Test") ' add the DL name as
Recipient

myForward.Save()
myForward.Send()
End Sub
 
K

Ken Slovak - [MVP - Outlook]

I'm not sure this will help with that but start by not creating an
Outlook.Application object. You are passed that in Startup() and that is the
trusted Application object you should use. Use
ThisAddin.Application.Application to get the Outlook.Application object.
 
E

Epelman

The solution I found is:
change myForward.Save()
by myForward.Display()
it works !

Tks !
 

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