GamerNeelie
New Member
- Joined
- May 21, 2022
- Messages
- 25
- Office Version
- 2013
- Platform
- Windows
I have a working email script that I've been using for sometime.
Once the user clicks a button it will run the script and open a new window for the email
However i would like a message box to appear asking the user if they would like to continue with the email (If they clicked it by mistake etc)
I just unsure where in the script I would add it for it to work correctly
Example of the kind of box i want to add
Example of my Email Script:
Once the user clicks a button it will run the script and open a new window for the email
However i would like a message box to appear asking the user if they would like to continue with the email (If they clicked it by mistake etc)
I just unsure where in the script I would add it for it to work correctly
Example of the kind of box i want to add
VBA Code:
Dim answer As Integer
answer = MsgBox("Are you sure you wish to email", vbOKCancel)
Else
MsgBox "Email Cancelled"
Example of my Email Script:
VBA Code:
Sub Email1()
Dim OutApp As Object
Dim OutMail As Object
Dim NewWB As String
Dim filename1 As String
filename1 = Sheet2.Range("AF20").Value & " - " & Sheet2.Range("AC21").Value & " " & Sheet2.Range("AC22").Value & " - " & Sheet2.Range("AC23").Value
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'On Error Resume Next
With OutMail
.To = Range("AJ18").Value
.CC = "******"
.BCC = ""
.Subject = "********
.Body = "*********
.Attachments.Add ThisWorkbook.Path & Application.PathSeparator & filename1 & ".xlsm"
'.Send
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Kill ThisWorkbook.Path & Application.PathSeparator & filename1 & ".xlsm"
End Sub