在电子邮件正文中发送文件,而不是作为附件vbscript

在电子邮件正文中发送文件,而不是作为附件vbscript,vbscript,cdo.message,Vbscript,Cdo.message,我正在使用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\out

我正在使用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

您可以使用创建电子邮件正文作为HTML和

。。。。。。。。。。。。。
身体
.......
......
...............
为此,您必须在电子邮件标题中设置一位

例如:

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
尺寸fso,输出文件
设置fso=CreateObject(“Scripting.FileSystemObject”)
Set outFile=fso.CreateTextFile(“output.txt”,True)
'mailman对象用于发送和接收电子邮件。
设置mailman=CreateObject(“Chilkat_9_5_0.mailman”)
'任何字符串参数都会自动开始30天的试用。
成功=mailman.UnlockComponent(“30天试用”)
如果(成功1)那么
outFile.WriteLine(mailman.LastErrorText)
WScript.Quit
如果结束
'设置SMTP服务器。
mailman.SmtpHost=“smtp.comcast.net”
'创建新的电子邮件对象
设置email=CreateObject(“Chilkat\u 9\u 5\u 0.email”)
'将嵌入图像添加到HTML电子邮件。
fileOnDisk=“images/dude2.gif”
filePathInHtml=“dudeAbc.gif”
'在电子邮件中嵌入GIF图像。
成功=email.AddRelatedFile2(fileOnDisk,filePathInHtml)
如果(成功1)那么
outFile.WriteLine(mailman.LastErrorText)
WScript.Quit
如果结束
'图像标记的src属性设置为filePathInHtml:
htmlBody=“嵌入图像:
” '设置基本的电子邮件内容:HTML正文、主题、“发件人”、“收件人”; email.SetHtmlBody htmlBody email.Subject=“带有嵌入图像的VBScript HTML电子邮件。” 成功=email.AddTo(“Admin”admin@chilkatsoft.com") email.From=“Chilkat支持” success=mailman.sendmail(电子邮件) 如果(成功1)那么 outFile.WriteLine(mailman.LastErrorText) 其他的 outFile.WriteLine(“邮件已发送!”) 如果结束 出口,关闭
您好,我正在使用上述脚本发送电子邮件,请建议我如何修改。您能否确切地告诉我,您没有从上述书面代码中得到什么!!!我可以获取电子邮件,但无法获取电子邮件正文的附件。这是使用第三方付费组件,您可以使用CDO for Windows免费完成此操作。如果您希望
output.txt
的内容成为
TextBody
,您需要使用
Scripting.FileSystemObject
ADODB.Stream
加载的内容,以打开文件并将其内容读入变量。
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