Hello Everyone,
I would like my Email XLSM button to do the following:
1. User clicks the Email button
2. The current xlsm workbook is saved to a temp directory, with the current date appended
3. A new Outlook email dialog box is summoned that attaches the workbook.
4. If the user clicks send, the message sends (obviously)
5. If the user exits out of the message without sending, a msgbox appears saying "Send Email Canceled"
6. If the outlook app was opened by excel, then close the outlook app after sending.
The code I have is here but it doesn't work and saves the workbook in the current directory.
Thank you!!!!
I would like my Email XLSM button to do the following:
1. User clicks the Email button
2. The current xlsm workbook is saved to a temp directory, with the current date appended
3. A new Outlook email dialog box is summoned that attaches the workbook.
4. If the user clicks send, the message sends (obviously)
5. If the user exits out of the message without sending, a msgbox appears saying "Send Email Canceled"
6. If the outlook app was opened by excel, then close the outlook app after sending.
The code I have is here but it doesn't work and saves the workbook in the current directory.
Code:
Private Sub CommandButton2_Click()
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
On Error Resume Next
With OutlookMail
.To = ""
.CC = ""
.BCC = ""
.Subject = ""
.Body = ""
.Attachments.Add Application.ActiveWorkbook.FullName
.Send
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub
Thank you!!!!