VigneshSimha
New Member
- Joined
- Apr 29, 2021
- Messages
- 1
- Office Version
- 2016
- Platform
- 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
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