ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Send email from vba code in excel (https://www.excelbanter.com/excel-discussion-misc-queries/262844-send-email-vba-code-excel.html)

Melisa Hutchins

Send email from vba code in excel
 
Help!
I need to write code to send a work book when it is saved or when it is closed. This is what I have but it will not send the email. I am using excel 2003. I am very new to VBA.

Sub Email()
Dim OutApp As Object
Dim OutMail As Object
email_ = Range("F5") & ";" & Range("F3")
cc_ = ""
subject_ = "Flagged Order"
body_ = "New Flagged Order"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = email_
.Subject = subject_
.Body = body_
.CC = cc_
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End With
End With
End Sub

Norm

Send email from vba code in excel
 
I had the same question please look at the help I recieved it worked for me
see the threads: For Outlook "auto email worksheet and for Lotus Notes see:
"Outlook vs Lotus Notes in macros"

"Melisa Hutchins" wrote:


Help!
I need to write code to send a work book when it is saved or when it is
closed. This is what I have but it will not send the email. I am using
excel 2003. I am very new to VBA.

Sub Email()
Dim OutApp As Object
Dim OutMail As Object
email_ = Range("F5") & ";" & Range("F3")
cc_ = ""
subject_ = "Flagged Order"
body_ = "New Flagged Order"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = email_
.Subject = subject_
.Body = body_
.CC = cc_
.Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End With
End With
End Sub




--
Melisa Hutchins
.



All times are GMT +1. The time now is 12:58 PM.

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