我正在尝试使用 VBA 代码发送电子邮件,该功能正在运行并且电子邮件已发送,但问题是当函数结束时出现“运行时错误 438 对象不支持此属性或方法”
这是代码:
Public Function SendEmail(ItemName As String, Total_Qnty As Integer)
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' send one copy with Google SMTP server (with autentication)
schema = "http://schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = 2
Flds.Item(schema & "smtpserver") = "smtp.gmail.com"
Flds.Item(schema & "smtpserverport") = 465
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "sendusername") = "example@gmail.com"
Flds.Item(schema & "sendpassword") = "*****"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
.To = "example@hotmail.com"
.From = "example@gmail.com"
.Subject = "Mail from gmail"
.HTMLBody = "The Stock Safty Level of Item: " & ItemName & " is DOWN, The total quantity you have is: " & Total_Qnty & "!!"
Set .Configuration = iConf
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
End Function
很高兴任何想法..谢谢