Macro Help!!

Aharon

Honorary Master
Joined
Sep 12, 2006
Messages
10,595
Reaction score
516
Hi Everyone,

I am trying to find a macro that I can use in Excel to attached a particular file to an email, enter the email address and send it.

The tricky part seems to be to get the macro to do everything including send and attach.

Please, please can someone help me :)
 
Then post the code(s) that doesn't work, you'll get more replies that way.
 
If you need a powershell code for that I can help if you wanted to script something.
I dont know macros that well but ive done some Powershell coding, might help someone else reading this:

$filename = “excelfile1.xls”
$filename2 = “excelfile2.xls”
$SMTPserver = "your email server"

$msg = new-object Net.Mail.MailMessage
$att1 = new-object Net.Mail.Attachment($filename)
$att2 = new-object Net.Mail.Attachment($filename2)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)

$msg.From = “Your Name <[email protected]>”
$msg.To.Add(”John Doe <[email protected][/email]>”)
$msg.Subject = “The subject comes here”
$msg.Body = “Emailbody comes here <br> next line <br> next line”
$msg.Attachments.Add($att1)
$msg.Attachments.Add($att2)
$msg.IsBodyHTML = $true
$smtp.Send($msg)
 
Top
Sign up to the MyBroadband newsletter
X