Attach file to e-mail using excel macro
Thanks for the help. This was what I was looking for. However if I execute
this code multiple times it is almost as if the file to be attached is saved
to a clipboard. Each subsequent time I execute the code the previously
attached file is also added. i.e. If I run the code a second time it not
only attaches the file selected by the code but also the file selected by the
code when run previously. Is there a way to "clear" the clipboard so only
the one file is attached?
"arjen van..." wrote:
Try something like this:
Sub NewMail()
ActiveWorkbook.EnvelopeVisible = True
Dim strAttachment As String
strAttachment = "C:\customers.txt"
With ActiveSheet.MailEnvelope
.Introduction = Range("T22")
.Item.To = Range("T15")
.Item.CC = Range("T16")
.Item.Subject = "CST CARRIERS"
.Item.Send
.Item.Attachments.Add strAttachment
End With
End Sub
Though I think creating the string variable isn't essential, you could just
put the path directly after .Add
|