Send E-mail from excel Macro

VigneshSimha

New Member
Joined
Apr 29, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Dear All,

I have written a macro to send E-mails to different users with attachments. It is working fine in my personal laptop. But when i try this on my company laptop .send is not working. I am getting run time error 429, .display is working fine. Please find below my macro and please help me on this.


Sub sendemails()

Dim Output As Outlook.Application
Dim outmail As MailItem
Dim sh As Worksheet
Dim cell As Range
Dim Filecell As Range
Dim rng As Range
Dim oExcel As Excel.Application


With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set sh = Sheets("Sheet1")

Set outapp = CreateObject("Outlook.Application")
Set oExcel = CreateObject("Excel.Application")


For Each cell In sh.Columns("A").Cells.SpecialCells(xlCellTypeConstants)

'path/file names are entered in the columns D:M in each row
Set rng = sh.Cells(cell.Row, 1).Range("E1:M1")

If cell.Value Like "?*@?*.?*" And _
Application.WorksheetFunction.CountA(rng) > 0 Then

Set outmail = outapp.CreateItem(olMailItem)


With outmail

.CC = sh.Cells(cell.Row, 2).Value
.Subject = sh.Cells(cell.Row, 3).Value
.Body = sh.Cells(cell.Row, 4).Value


For Each Filecell In rng.SpecialCells(xlCellTypeConstants)

If Trim(Filecell.Value) <> "" Then
If Dir(Filecell.Value) <> "" Then
.Attachments.Add Filecell.Value
End If
End If
Next Filecell
.Send
'.display

End With
Set outmail = Nothing

End If

Next cell

Set outapp = Nothing

With Application
.EnableEvents = True
.ScreenUpdating = True
End With


End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,141,705
Messages
5,707,973
Members
421,539
Latest member
zuniBM

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
Top