Re: Here's one way to do it
Hi Bill:
You can paste this code into your procedure (after customizing it to suit your file name, send to, CC, and body message text, etc).
One tip, keep in mind that the ".Display" line in the With structure will just display the email. If you want to cut to the chase in your code and simply have the email get sent, replace ".Display" with ".Send".
Also with this code, Outlook does not need to be open when the code is run so it should be convenient for you in that respect.
Hope this helps,
Tom Urtis
Dim myOutlook As Object
Dim myMailItem As Object
Set otlApp = CreateObject("Outlook.Application")
Set otlNewMail = otlApp.CreateItem(olMailItem)
fName = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name
With otlNewMail
.To = "JohnDoe@anywhere.com; JaneSmith@anyplace.com"
.CC = MaryJones@anycompany.com
.Subject = Todays Report"
.Body = "Attached is today's Report." & Chr(13) & "Regards," & Chr(13) & "Bill" & Chr(13) & Chr(13)
.Attachments.Add fName
.Display
End With
Set otlNewMail = Nothing
Set otlApp = Nothing
Set otlAttach = Nothing
Set otlMess = Nothing
Set otlNSpace = Nothing
Re: Here's one way to do it
Um... Okay. I gather this is a macro code that I paste into the virtual basic editor? (If I can remember how I did that the first time!)
I have almost NO experience with macros or handling code.
Could you elaborate a little further please?
Thanks.
Bill.
OH! I got it... but what about...
OH! Okay. I got the macro to work with a clickable button. THANK YOU SO MUCH!!
...but while I'm at it, is there a way to have the "regards" automatically select the name of the person who is sending the e-mail? (from:)?
Re: OH! I got it... but what about...
Bill --
If you are referring to the name in the body of the emial, I'd defer to someone else who knows if that is(n't) possible. Otherwise, the sender's name in the "From" line of Outlook will automatically appear as the name assigned to Outlook or logged on to that computer from which you are working if you are on a LAN or WAN in your office, which I presume you are if you are using Outlook for your inter- and intra-office email carrier.
Sorry about just dumping the code on you without the prelims earlier, I thought you had been working in VB code already given the question but it sounds like you worked it out since.
Good luck.
Tom
Thanks again.
Regards,
Bill Bill -- If you are referring to the name in the body of the emial, I'd defer to someone else who knows if that is(n't) possible. Otherwise, the sender's name in the "From" line of Outlook will automatically appear as the name assigned to Outlook or logged on to that computer from which you are working if you are on a LAN or WAN in your office, which I presume you are if you are using Outlook for your inter- and intra-office email carrier. Sorry about just dumping the code on you without the prelims earlier, I thought you had been working in VB code already given the question but it sounds like you worked it out since. Good luck. Tom : OH! Okay. I got the macro to work with a clickable button. THANK YOU SO MUCH!! : ...but while I'm at it, is there a way to have the "regards" automatically select the name of the person who is sending the e-mail? (from:)?
: Um... Okay. I gather this is a macro code that I paste into the virtual basic editor? (If I can remember how I did that the first time!)