Group Email and File Distribution

becullen619

New Member
Joined
Mar 29, 2010
Messages
1
I am trying to write a macro which will copy a range of cells into an Outlook email and add an attachment which will be sent to a group of people on a distribution list, also included in the workbook.

The code I am using is:

Sub Cash_Email()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim strto As String

Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")

On Error GoTo cleanup
For Each cell In ThisWorkbook.Sheets("Distrib").Range("A1:A10")
If cell.Value Like "?*@?*.?*" Then
strto = strto & cell.Value & ";"
End If
If Len(strto) > 0 Then strto = Left(strto, Len(strto) - 1)
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.Subject = "Daily Liquidity"
.Body = Cells(cell.Row, "A1:B12").Value _
& vbNewLine & vbNewLine & _
"Cash File Attached"
'You can add files also like this
.Attachments.Add ("S:\2010\TREASURY\03 - March 2010\2010 March Daily Dashboard.xls")
.Send 'Or use Display
End With
On Error GoTo 0
Set OutMail = Nothing
Next cell


cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
moz-screenshot-1.png

moz-screenshot.png

However, the code seems to get hung up on the line:
" Set OutMail = OutApp.CreateItem(0)"
and looping in my Outlook, asking me over and over if I want to send an email, but never sending one.

Anyone have any ideas?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,215,684
Messages
6,126,199
Members
449,298
Latest member
Jest

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