我正在尝试设置宏以将消息发送到我在 Excel 工作表中的电子邮件地址。
我在 F3 字段中有消息主题,在 F4 字段中有消息
数据从第 14 行开始
最后看起来如下(使用的宏在问题的底部:
我执行宏,结果邮件被发送,但格鲁吉亚文本被破坏,问号而不是格鲁吉亚字母。
我不明白这里出了什么问题,是宏在这样做还是 Gmail 破坏了我的邮件文本?结果如下:
您可以看到格鲁吉亚文字已损坏。
对此有何建议?它会发生什么以及如何纠正这个问题?
Sub SendWith_SMTP_Gmail()
'Works On Windows (Not Mac). Mac Users Should Use Zapier Integration
'Created by Randy Austin www.ExcelForFreelancers.com
Dim EmailMsg, EmailConf As Object
Dim Subj, Mess, Json, URL, LastName, FirstName, Email, Attach As String
Dim ContactRow, LastRow, SentCounter As Long
Dim EmailFields As Variant
Set EmailMsg = CreateObject("CDO.Message") 'CDO (Collaboration Data Objects) -Make sure you have the 'CDO For Windows' Library Selected
Set EmailConf = CreateObject("CDO.Configuration")
EmailConf.Load -1 ' Set CDO Source Defaults
Set EmailFields = EmailConf.Fields
With EmailFields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "My-Gmail-Address@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "My-G-Mail-Pass"
.Update
End With
With Sheet1
Attach = .Range("F11").Value 'Attachment Link
LastRow = .Range("E999").End(xlUp).Row 'Get Last Row Of Table
For ContactRow = 14 To LastRow
Subj = .Range("F3").Value 'Email Subject
Mess = .Range("F4").Value 'Email Message
If .Range("L" & ContactRow).Value <> Empty Then GoTo NextRow
LastName = .Range("E" & ContactRow).Value
FirstName = .Range("F" & ContactRow).Value
Email = .Range("K" & ContactRow).Value
Subj = Replace(Replace(Subj, "#FirstName#", FirstName), "#LastName#", LastName)
Mess = Replace(Replace(Mess, "#FirstName#", FirstName), "#LastName#", LastName)
With EmailMsg
Set .Configuration = EmailConf
.To = Email
.CC = ""
.BCC = ""
.From = """info"" <info@mail.ge>"
.Subject = Subj
If Attach <> Empty Then .AddAttachment Attach
.TextBody = Mess
.Send
End With
SentCounter = SentCounter + 1
.Range("L" & ContactRow).Value = Now 'Set Send Date & Time
NextRow:
Next ContactRow
'Cleanup
Set EmailMsg = Nothing
Set EmailConf = Nothing
Set EmailFields = Nothing
End With
MsgBox SentCounter & " Emails have been sent"
End Sub