Email Macro works in 2007 and not in 2010

wes mcallister

New Member
Joined
May 19, 2011
Messages
4
I have a macro that sends an email. This works fine in both 2003 and 2007 when outlook is not running. But in 2010 it does not work. Any thoughts or fixes.

Sub mail_text()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim Req As String
Dim qty1 As String

strbody = "Hi Wes" & vbNewLine & vbNewLine & _
"I have created a new Requisition" & vbNewLine & _
"The Request # is " & Range("L2")

Set OutApp = CreateObject("Outlook.Application")
'Set OutApp = GetObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.Subject = "New Request # " & Range("L2")
.To = ""
'.CC = ""
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = strbody
.Display
'.Send


End With

On Error GoTo 0

Set OutMail = Nothing

Set OutApp = Nothing
End Sub
 

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).
Have you tried commenting-out the "On Error Resume Next" and stepping through the code in debug-mode to determine exactly where it is failing?
 
Upvote 0
Hi Wes,

I normally have my Outlook open all day so I don't get this sort of problem.
I am working with 2007 and have tried mailing with Outlook closed.
If I set 'Send Immediately when connected' in Tools>Options>Mail Setup then the mail is sent otherwise it stays in the Outbox until Outlook is opened.

Perhaps 2010 is the same and the box isn't ticked?

Also I have to set the macro to use .display and .send
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,671
Members
452,937
Latest member
Bhg1984

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