0

I currently have a vba code that is activated by a button in excel that copies certain information from the sheet into an outlook email. Having updated to win64 and updating the declare statements etc. I can not get it to open an outlook email window. What is the new code to open the outlook application window from within excel via win64

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45

1 Answers1

1

The following code works like a charm on my machine with Office x64 installed:

Dim applOL As Outlook.Application
Dim miOL As Outlook.MailItem

'Create a new instance of the Outlook application. Set the Application object as follows:
Set applOL = New Outlook.Application
'create mail item:
Set miOL = applOL.CreateItem(olMailItem)
 
With miOL
 .To = "name@domain.com"
 .Subject = "Mail Automation"
 .Body = "Sending the Active Excel Workbook as attachment!"
 'add host workbook as an attachment to the mail:
 .Attachments.Add ActiveWorkbook.FullName
 .Display
End With

'clear the object variables:
Set applOL = Nothing
Set miOL = Nothing

Don't forget to add an Outlook COM reference in your VBA environment.

Also you may find the following articles helpful:

Also take a look at the Automating Outlook from Other Office Applications article.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45