ms-access - VBA 取消发送由 Gmail 发送的电子邮件
问题描述
我知道 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
解决方案
推荐阅读
- arduino-uno - 与 Arduino 连接的 HC-05 模块在 3 秒后停止向 Android 应用程序发送数据
- python - 从 Pyspark UDF 调用另一个自定义 Python 函数
- javascript - 拉姆达:哪里有?
- c# - XAML 属性集顺序优化
- python - 如何从 tkinter 条目小部件中获取值,以便对其进行验证?
- java - 如何获取和索引数组对象
- axapta - 请求的任务无法在 \Forms\AB\DataSources\XY\Methods\displayOption 上执行
- amazon-web-services - 确认后不会触发 lambda 函数
- php - 如何使用 TwitterAPIExchange 按国家/地区查找关注度最高的帐户?
- gulp - 运行 gulp.series() 的问题