I am not an experienced programmer but I need to resolve a problem I am having with an Excel Office 2003 VBA Macro.
I have some code (see below) that will send an email just fine while avoiding the Outlook security message. Unfortunately, our GAL is somewhat messed up, so if the code doesn't get a clean address is stops the email and presents the GAL asking the user to pick the address they want to send. All this is okay, but I can't tell under this circumstance if the user sent the email or pressed the x button to close the window.
So, I need to do one of two things. Either control the window closing like with Thisworkbook before_close, OR an IF THEN test to determine if the email was sent.
I really hope some one can help, and thank you in advance.
Michael
Dim OutApp As Object
Dim outmail As Object
Set OutApp = CreateObject("Outlook.Application")
Set outmail = OutApp.CreateItem(0)
With outmail
.To = "email@address.com"
.CC = ""
.BCC = ""
.Subject = ""
.Body = ""
.Attachments.Add ActiveWorkbook.FullName
.Display
'work around for the Outlook security warning message
Application.Wait (10)
SendKeys "^{Enter}", 5
End With
Set outmail = Nothing
Set OutApp = Nothing
I have some code (see below) that will send an email just fine while avoiding the Outlook security message. Unfortunately, our GAL is somewhat messed up, so if the code doesn't get a clean address is stops the email and presents the GAL asking the user to pick the address they want to send. All this is okay, but I can't tell under this circumstance if the user sent the email or pressed the x button to close the window.
So, I need to do one of two things. Either control the window closing like with Thisworkbook before_close, OR an IF THEN test to determine if the email was sent.
I really hope some one can help, and thank you in advance.
Michael
Dim OutApp As Object
Dim outmail As Object
Set OutApp = CreateObject("Outlook.Application")
Set outmail = OutApp.CreateItem(0)
With outmail
.To = "email@address.com"
.CC = ""
.BCC = ""
.Subject = ""
.Body = ""
.Attachments.Add ActiveWorkbook.FullName
.Display
'work around for the Outlook security warning message
Application.Wait (10)
SendKeys "^{Enter}", 5
End With
Set outmail = Nothing
Set OutApp = Nothing