VBA Отмена отправить письмо, отправленное Gmail - PullRequest
0 голосов
/ 13 сентября 2018

Я знаю, что Google Gmail был функцией отмены отправленного письма в течение 30 секунд.

Поскольку я использую этот код для отправки электронных писем из базы данных доступа и через gmail, я хотел бы знать, есть ли способ использовать эту функцию, чтобы предотвратить отправку электронного письма по ошибке?

Sub SendEmail_Click()
Dim NewMail As CDO.Message
Set NewMail = New CDO.Message

'Enable SSL Authentication
NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

'Make SMTP authentication Enabled=true (1)

NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

'Set the SMTP server and port Details
'To get these details you can get on Settings Page of your Gmail Account

NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

'Set your credentials of your Gmail Account

NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mysite@gmail.com"

NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword7"

'Update the configuration fields
NewMail.Configuration.Fields.Update

'Set All Email Properties

With NewMail
Dim strPath As String
strPath = ".mysite/wp-content/uploads/2017/07/myimage.png"
.subject = "this is the subject"
.From = "<mail@mysite.com>"
.To = Me.EMAIL
'.CC = ""
'.BCC = ""
.HTMLBody = "This is my message body"
.AddAttachment "https://mysite/temp/contacts.vcf"
End With

NewMail.Send
MsgBox ("This email was sent!")

'Set the NewMail Variable to Nothing
Set NewMail = Nothing

End Sub
...