Hello -
I am using automation in Office 2000 to control Outlook from Excel. I have a button on my worksheet to allow the user to email the workbook back to me directly from Excel. My problem is in determing if the e-mail was actually sent or if the user backed out and decided not to send it after I show Outlook. Here is my code:
Private Sub cmdEmail_Click()
Dim outApp As Outlook.Application
Dim outMail As Outlook.MailItem
Set outApp = CreateObject("Outlook.Application"
Set outMail = outApp.CreateItem(olMailItem)
'If the user tries to e-mail before they process the form, then that is okay as long as we
' validate the data and populate the Data worksheet first
If ValidInput = False Then
Exit Sub
End If
If MsgBox("Would you like to save the form before e-mailing?", vbYesNo, "Save"
= vbYes Then
cmdSave_Click
End If
'We made it through the ValidateInput Sub, so we have good data
'...So we continue by loading the proper values on the Data worksheet
PopulateDataWS
With outMail
.To = "glalsop@emailaddress.com"
.Subject = "Talent Development Pilot - Manager Form"
.Attachments.Add ActiveWorkbook.FullName
.Display
End With
If outMail.Submitted = True Then
MsgBox "Thank you for completing the SunTrust Talent Development Pilot." & vbCrLf & _
"Your e-mail has been sent successfully."
Else
MsgBox "Your e-mail was NOT transmitted successfully." & vbCrLf & _
"In order for these forms to be processed properly, they must be re-submitted via e-mail.", _
, "Unsuccessful Transmission"
End If
Set outMail = Nothing
Set outApp = Nothing
End Sub
I have also tried the Sent property in place of the Submitted property but my If statement always evaluates to False even if I do send the e-mail.
Thanks in advance for any suggestions.
-Gary
I am using automation in Office 2000 to control Outlook from Excel. I have a button on my worksheet to allow the user to email the workbook back to me directly from Excel. My problem is in determing if the e-mail was actually sent or if the user backed out and decided not to send it after I show Outlook. Here is my code:
Private Sub cmdEmail_Click()
Dim outApp As Outlook.Application
Dim outMail As Outlook.MailItem
Set outApp = CreateObject("Outlook.Application"
Set outMail = outApp.CreateItem(olMailItem)
'If the user tries to e-mail before they process the form, then that is okay as long as we
' validate the data and populate the Data worksheet first
If ValidInput = False Then
Exit Sub
End If
If MsgBox("Would you like to save the form before e-mailing?", vbYesNo, "Save"
cmdSave_Click
End If
'We made it through the ValidateInput Sub, so we have good data
'...So we continue by loading the proper values on the Data worksheet
PopulateDataWS
With outMail
.To = "glalsop@emailaddress.com"
.Subject = "Talent Development Pilot - Manager Form"
.Attachments.Add ActiveWorkbook.FullName
.Display
End With
If outMail.Submitted = True Then
MsgBox "Thank you for completing the SunTrust Talent Development Pilot." & vbCrLf & _
"Your e-mail has been sent successfully."
Else
MsgBox "Your e-mail was NOT transmitted successfully." & vbCrLf & _
"In order for these forms to be processed properly, they must be re-submitted via e-mail.", _
, "Unsuccessful Transmission"
End If
Set outMail = Nothing
Set outApp = Nothing
End Sub
I have also tried the Sent property in place of the Submitted property but my If statement always evaluates to False even if I do send the e-mail.
Thanks in advance for any suggestions.
-Gary