Multiple email error

Akshay_divecha

Board Regular
Joined
Mar 11, 2014
Messages
70
Dear Experts,

Getting error while sending email, need your advise on how to fix it..

Screenshot_1.png


[
VBA Code:
Sub SendEmail()
'
' SendEmail Macro
'

'
row_number = 1

Do
DoEvents
    row_number = row_number + 1
    
    Dim OutApp As Object
    Dim OutMail As Object
    Dim OutMailBody As String


    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
    
        .To = Sheet1.Range("A" & row_number)
        .CC = Sheet1.Range("B" & row_number)
        .Subject = Sheet1.Range("J" & row_number)
        .Body = Sheet1.Range("I" & row_number)
        .Display   'or use .Display
    End With
    On Error GoTo 0
    
Loop Until Last_Row_IN_Column_A = Sheet1.Range("A50").End(xlUp)

    Set OutMail = Nothing
    Set OutApp = Nothing
      
MsgBox "Mail sent"
    
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
How about

VBA Code:
Sub SendEmail()
' SendEmail Macro
  Dim OutApp As Object, OutMail As Object, i As Long
  '
  On Error Resume Next
  For i = 2 To Range("A" & Rows.Count).End(3).Row
    Set OutApp = CreateObject("outlook.application")
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
      .to = Sheet1.Range("A" & i)
      .CC = Sheet1.Range("B" & i)
      .Subject = Sheet1.Range("J" & i)
      .Body = Sheet1.Range("I" & i)
      .Display   'or use .Display
    End With
  Next
  Set OutMail = Nothing
  Set OutApp = Nothing
  MsgBox "Mail sent"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,583
Messages
6,125,665
Members
449,247
Latest member
wingedshoes

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