Forum Discussion
Macros
Hi Community,
I have created a tool using macros in office 2016 however it is not running in 2010 version. Kindly suggest how can I run it in both. Please go through the code for your reference.
Sub Sent_Email()
Dim OAEmail As Outlook.Application
Set OAEmail = New Outlook.Application
Dim OAEmailItem As Outlook.MailItem
Set OAEmailItem = OAEmail.CreateItem(olMailItem)
OAEmailItem.To = Sheets("Email").Range("C8")
OAEmailItem.CC = Sheets("Email").Range("C9")
OAEmailItem.Subject = Sheets("Email").Range("C11")
OAEmailItem.Body = Sheets("Email").Range("C14") & vbNewLine & _
Sheets("Email").Range("C15") & vbNewLine & vbNewLine & _
Sheets("Email").Range("C16") & vbNewLine & vbNewLine & _
Sheets("Email").Range("C17") & vbNewLine & vbNewLine & _
Sheets("Email").Range("C18")
OAEmailItem.Display
End Sub
2 Replies
- Subodh_Tiwari_sktneerSilver Contributor
What happens when you run this? Do you get an error or what?
In the 2010 version file, did you add Reference to the Microsoft Outlook Object Library since you are using the early binding method?
- rrMalladeCopper ContributorHi Subhodh,
Thank you for your reply, I got that error fixed however I need some addition on that file. I am not great in VBA. I have attached that file in a different discussion. Here's the link for it https://techcommunity.microsoft.com/t5/excel/vba-code-support/m-p/2665279
It will great if you could help me with it.
Thanks