VBA - Excel file by e-mail

Patrice74

New Member
Joined
Dec 3, 2018
Messages
10
Hello,

I have a VBA which ouput is 13 excel files saving in my drev. i Would like to send them by email. It is not the samme receiver for every files (7 different receiver). Is there somebody who can help me with a VBA? Thanks a lot :)
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Welcome to the forum,

Is the list of receivers always the same? How do you determine which file is sent to which receiver?
 
Upvote 0
Welcome to the forum,

Is the list of receivers always the same? How do you determine which file is sent to which receiver?

Hi,
Thank you very much
I have :
column A: attachment filenames (e.g files1.xls;files2.xls)
Column B: mail adress
Column C: te file path for te attachment files

:)
BR
Patrice
 
Upvote 0
I have created the following code for you to use, I have tested it, seems to work ok. You may have to adapt it a little, things like sheet name may have to change:

Sub EmailList1A()
'Using object to create early and late binindg
'Column A holds file name
'Column B holds email address
'Column C holds path
Dim OutApp As Object
Dim OutMail As Object
Dim Cell As Range
'Switch off updating screen
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
'Create error trap
On Error GoTo cleanup
Sheets("Sheet1").Activate 'Change the sheet name if not sheet1
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 = Cells(Cell.Row, "A").Value
.body = "Please find attached file for your review\action"
.Attachment.Add Cells.Columns("C").Value & Cells.Columns("A").Value
' Once tested change the next line to .Send
.display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next Cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,064
Messages
6,128,562
Members
449,458
Latest member
gillmit

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