VisualFreeBasic代码_网络

2026-1-21 / 0 评论 / 63 阅读

网络编程,使用 ”WinInet“ 互联网访问 和 ”Network“ 网络通信 控件编写。

还有一个发送电子邮件代码

#include Once "Afx/CCDOMail.inc"
' // 创建一个CCdoMessage类的实例
DIM pMsg AS CCDOMessage
' // 组态
pMsg.ConfigValue(cdoSendUsingMethod, CdoSendUsingPort)
pMsg.ConfigValue(cdoSMTPServer, "smtp.xxxxx.xxx")
pMsg.ConfigValue(cdoSMTPServerPort, 25)
pMsg.ConfigValue(cdoSMTPAuthenticate, 1)
pMsg.ConfigValue(cdoSendUserName, "xxxx@xxxx.xxx")
pMsg.ConfigValue(cdoSendPassword, "xxxxxxxx")
pMsg.ConfigValue(cdoSMTPUseSSL, 1)
pMsg.ConfigUpdate
' // 收件人姓名 - >根据需要更改
pMsg.Recipients("xxxxx@xxxxx")
' // 发件人邮件地址 - >根据需要更改
pMsg.From("xxxxx@xxxxx")
' // 主题 - >根据需要更改
pMsg.Subject("This is a sample subject")
' // 文字正文 - >根据需要更改
pMsg.TextBody("This is a sample message text")
' // 添加附件(使用绝对路径)。
' // 注意通过重复呼叫,您可以附加多个文件。
pMsg.AddAttachment ExePath & "\xxxxx.xxx"
' // 发送消息
pMsg.Send
IF pMsg.GetLastResult = S_OK THEN PRINT "Message sent" ELSE PRINT "Failure"
要使用gmail发送消息,只需更改服务器名称和服务器端口的值:
pMsg.ConfigValue(cdoSMTPServer, "smtp.gmail.com")
pMsg.ConfigValue(cdoSMTPServerPort, 465)

评论一下?

OωO
取消