使用CDO发送电子邮件并首先检查连接状态
作者:互联网
Local iMsg,iConf Declare SHORT InternetGetConnectedState In wininet.Dll; INTEGER @lpdwFlags, Integer dwReserved lConnect=displayState() If lConnect iMsg = Createobject("CDO.Message") iConf = Createobject("CDO.Configuration") Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 'Your SMTP server name here' .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 .Update() Endwith With iMsg .Configuration = iConf .To = "me@hotmail.com" .CC = "" .BCC = "" .From = "me@somewhere.com" .Subject = "This is a test" .Fields("Priority").Value = 1 && -1=Low, 0=Normal, 1=High .Fields.Update() .TextBody = "This is the body text" && Plain text **.HTMLBody = "This is the HTML body text" && Optional HTML message .AddAttachment( "C:/" + lcFilename) && Valid filename .Send() Endwith iMsg = .Null. iConf = .Null. Flds = .Null. Else Messagebox("Could not send the message, you internet connection is down.") Endif Procedure displayState Local lConnected lConnected = .F. lpdwFlags = 0 If InternetGetConnectedState (@lpdwFlags, 0) = 1 lConnected = .T. Endif Return lConnected Endproc
标签:iMsg,text,CDO,发送,iConf,lConnected,&&,电子邮件,com 来源: https://www.cnblogs.com/chinancsa/p/15960045.html