Macro to Send Different Files to Differrent Emails

shaker93

New Member
Joined
Feb 22, 2018
Messages
6
Hello.

Please help me with this.
I am trying to create a macro in which i can send different files to different emails.
I was looking in this site and others and i came up with this code.

================================

Sub asddddddddddddd()

Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim i As Integer



Application.ScreenUpdating = False


Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Reminder"
.Body = "Dear " & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"Please contact us to discuss bringing " & _
"your account up to date"
.Attachments.Add ThisWorkbook.Sheets("Sheet1").Range("C" & i)
.Send 'Or use Display.
End With
On Error GoTo 0
Set OutMail = Nothing
Set oMail = Nothing
Set oApp = Nothing
End If
Next cell

cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
==========================================

In column A I put the name of the person
B the emails
C the file path

The problem is that when i run the macro, no attachment is sent, but the rest of the message is.
I do not know why

Can you help me
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Re: Question

Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,417
Messages
6,124,789
Members
449,188
Latest member
Hoffk036

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