ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically EMailing a Spreadhsheet Upon Opening (https://www.excelbanter.com/excel-programming/325620-automatically-emailing-spreadhsheet-upon-opening.html)

Rod

Automatically EMailing a Spreadhsheet Upon Opening
 
I have a spreadsheet I would like to automatcially email itself upon opening.
It will always go to the same address. I use MS Outlook and Excel 2003. Is
this possible?

I am comfortable w/ Excel and Outlook put am not an accomplished programmer.
Is there help out there?

Thanks.

Bernie Deitrick

Automatically EMailing a Spreadhsheet Upon Opening
 
Rod,

Put the code below into a module (making changes as needed to the subject,
address, and message), set a reference to MS Outlook using Tools |
References.... and use the open event or an auto-open macro to run it.

HTH,
Bernie
MS Excel MVP

Sub EmailThisWorkBookNow()
Dim ol As Object
Dim myItem As Outlook.MailItem
Dim myMsg As String
Dim myAtts As Outlook.Attachments

Set ol = CreateObject("outlook.application")

myMsg = "Hi Rod," & Chr(10) & Chr(10)
myMsg = myMsg & "Here's that stupid file.... AGAIN!" & Chr(10) & Chr(10)
myMsg = myMsg & " Rod" & Chr(10)

Set myItem = ol.CreateItem(olMailItem)
myItem.to = "
myItem.Subject = "Subject Line"
myItem.Body = myMsg
Set myAtts = myItem.Attachments
myAtts.Add ThisWorkbook.FullName
myItem.Send

Set ol = Nothing

End Sub

"Rod" wrote in message
...
I have a spreadsheet I would like to automatcially email itself upon

opening.
It will always go to the same address. I use MS Outlook and Excel 2003.

Is
this possible?

I am comfortable w/ Excel and Outlook put am not an accomplished

programmer.
Is there help out there?

Thanks.





All times are GMT +1. The time now is 04:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com