email sent fron VB Com Addin with empty .body

  • Thread starter Thread starter Epelman
  • Start date Start date
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
 
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.
 
The solution I found is:
change myForward.Save()
by myForward.Display()
it works !

Tks !
 
Back
Top