Create Email With VBA Excel 2013 to Outlook 2010

madhattt

New Member
Joined
Jul 26, 2012
Messages
6
I have a problem creating an email with excel vba. I wrote code and created an addin that works on my computer. I have Excel 2013 and Outlook 2013. The addin also works on excel 2010 with outlook 2010.

The problem I am having is some of the computers in our company have Office 2013 installed, and use Outlook 2010. Some of the mail servers we have do not support Outlook 2013 yet. Whenever I run the code on those computers, it tries to open the 2013 version of outlook instead of the 2010 version. I set Outlook 2010 as the default and it still does the same thing.

My question is, is there another way to write the code so it launches the 2010 version instead of the 2013?

Here is the code I have now that works great on my computer.

Code:
Dim OutApp As Object
Dim OutMail As Object


    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)


    On Error Resume Next
    With OutMail
        .To = EmailRecip
        .Importance = 2
        .CC = ""
        .Subject = EmailSubject
        .Body = EmailBody & vbNewLine & " "
        .Attachments.Add ActiveWorkbook.FullName
        .Display
    End With
    On Error GoTo 0


    Set OutMail = Nothing
    Set OutApp = Nothing

Thank you in advance for any help.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
If Outlook 2010 is open, you can use:
'http://www.pcreview.co.uk/threads/send-all-emails-in-outbox-and-quit-using-vba.4014040/
Code:
Set oOutApp = GetObject(, "Outlook.Application.14")

CDO might be the better route.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top