Excel 2016 issuing an email through outlook 2016

Brombrough

New Member
Joined
Apr 10, 2017
Messages
49
Hi All,

The following getStandardEmail Function has worked for years. The user makes sure Outlook is open first.

I design in 2010 and works fine for me. However when one of my users opens it in excel 2016, with Outlook 2016 already open, it fails.

When they run it it starts going through the wizard to add emails for the first time on the machine. Outlook 2016 is definitely open.

My question is how do I fix is so it works for 2010, 2013 & 2016

Thanks in Advance

Public Function getStandardEmail()
'purpose gets standard email wording into 2 global variables
'g_strHTMLFoot1 = Wording before you add required
'g_strHTMLFoot2 = Wording to be added after your wording
'

Dim OL As Outlook.Application
Dim olMsg As Outlook.MailItem
Dim strHTMLFoot As String
Dim strHTMLFoot1 As String
Dim strHTMLFoot2 As String
Dim lngBodypos As Long

Set OL = New Outlook.Application
Set olMsg = OL.CreateItem(olMailItem)

olMsg.Display
strHTMLFoot = olMsg.HTMLBody

lngBodypos = InStr(1, strHTMLFoot, "******")
lngBodypos = InStr(lngBodypos, strHTMLFoot, ">")

g_strHTMLFoot1 = Left(strHTMLFoot, lngBodypos)
g_strHTMLFoot2 = Mid(strHTMLFoot, (lngBodypos + 1))


olMsg.Close olDiscard
Set olMsg = Nothing
Set OL = Nothing


End Function
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

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