即时通讯使用vbscript CDO进行邮件发送,但我希望附件作为电子邮件的正文,请您建议我。
strSMTPFrom = "kampati.vinay@testing.in"
strSMTPTo = "kampati.vinay@testing.in"
strSMTPRelay = "testing.in"
strTextBody = "MDaemon Q status"
strSubject = "MDaemon Q status"
strAttachment = "C:\MDaemon\output.txt"
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = strTextBody
oMessage.AddAttachment strAttachment
oMessage.Send
答案 0 :(得分:-1)
您可以将创建电子邮件正文用作HTML和
喜欢
.............
body
.......
<div><img src="linkOfImage" height="50px" width="50px"/></div>
......
...............
为此,您必须在电子邮件标题中设置一位。
示例:
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)
' The mailman object is used for sending and receiving email.
set mailman = CreateObject("Chilkat_9_5_0.MailMan")
' Any string argument automatically begins the 30-day trial.
success = mailman.UnlockComponent("30-day trial")
If (success <> 1) Then
outFile.WriteLine(mailman.LastErrorText)
WScript.Quit
End If
' Set the SMTP server.
mailman.SmtpHost = "smtp.comcast.net"
' Create a new email object
set email = CreateObject("Chilkat_9_5_0.Email")
' Add an embedded image to the HTML email.
fileOnDisk = "images/dude2.gif"
filePathInHtml = "dudeAbc.gif"
' Embed the GIF image in the email.
success = email.AddRelatedFile2(fileOnDisk,filePathInHtml)
If (success <> 1) Then
outFile.WriteLine(mailman.LastErrorText)
WScript.Quit
End If
' The src attribute for the image tag is set to the filePathInHtml:
htmlBody = "<html><body>Embedded Image:<br><img src=""dudeAbc.gif""></body></html>"
' Set the basic email stuff: HTML body, subject, "from", "to";
email.SetHtmlBody htmlBody
email.Subject = "VBScript HTML email with an embedded image."
success = email.AddTo("Admin","admin@chilkatsoft.com")
email.From = "Chilkat Support <support@chilkatsoft.com>"
success = mailman.SendEmail(email)
If (success <> 1) Then
outFile.WriteLine(mailman.LastErrorText)
Else
outFile.WriteLine("Mail Sent!")
End If
outFile.Close