System Error When Sending Mass Emails

rhurst89

New Member
Joined
Mar 17, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to program a macro button to send mass emails. However, when I run the code, I get an error that reads "System Error &H80004005 (-2147467259). Unspecified error." When I uncomment the "Display" option, it'll display all of the emails exactly as I need them to. However, when I uncomment the "Send" option, I get the error. Does anyone have an idea of what might be the issue? This is my code:

Sub send_mass_email()
Dim i As Integer
Dim name, email, trades, pgain, tgain, dfrom, dto, ddue, tdue, subject As String
Dim OutApp As Object
Dim OutMail As Object

body = ActiveSheet.TextBoxes("TextBox 1").Text

i = 4
'Loop down name column starting at row 2 column 1
Do While Cells(i, 1).Value <> ""

name = Cells(i, 3).Value
email = Cells(i, 5).Value
trades = Cells(i, 6).Value
pgain = Cells(i, 7).Value
tgain = Cells(i, 8).Value
dfrom = Cells(i, 9).Value
dto = Cells(i, 10).Value
ddue = Cells(i, 11).Value
tdue = Cells(i, 12).Value
subject = ActiveSheet.TextBoxes("TextBox 2").Text

'Replace place holders
body = Replace(body, "C1", name)
body = Replace(body, "C2", dfrom)
body = Replace(body, "C3", dto)
body = Replace(body, "C4", trades)
body = Replace(body, "C5", tgain)
body = Replace(body, "C6", pgain)
body = Replace(body, "C7", tdue)
body = Replace(body, "C8", ddue)

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.to = email
.subject = subject
.body = body
'.display
.Send
End With

'reset body text
body = ActiveSheet.TextBoxes("TextBox 1").Text

i = i + 1
Loop

Set OutMail = Nothing
Set OutApp = Nothing
MsgBox "Email(s) Sent!"

End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I suspect it may be a timing issue, ie too many emails trying to be sent at once. Try adding a brief delay after each message to allow it time to actually send...perhaps something like:
Application.Wait Now + TimeValue("00:00:01")
 
Upvote 0

Forum statistics

Threads
1,214,790
Messages
6,121,608
Members
449,038
Latest member
apwr

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