首先,我并不是一个真正的程序员而且几乎不能完成这个
我想使用outlook发送定期发送的电子邮件,所以我谷歌它,发现我在记事本中写的这个脚本然后将其保存在.vbs中,并且消息正文使用HTML,之后我将计划任务设置为自动。 它真的与我合作,但现在我想添加一个附件到这个电子邮件我搜索很难但没有找到任何可以使用这个脚本和大问题,大多数时间我不明白任何事情,所以我希望如果有人可以帮助我,这就是我使用的脚本
Dim olkApp
Dim olkSes
Dim olkMsg
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNamespace("MAPI")
olkSes.Logon olkApp.DefaultProfileName
Set olkMsg = olkApp.CreateItem(0)
With olkMsg
'On the next line enter the email address of the person you want to send to'
.Recipients.Add "to email"
.Recipients.ResolveAll
'On the next line enter the email subject'
.Subject = "Reminder Email"
'On the next line enter your message. You can use HTML formatting.'
.HTMLBody = "here i put my message using HTML"
.Send
End With
Set olkMsg = Nothing
olkSes.Logoff
Set olkSes = Nothing
Set olkApp = Nothing
我想在此电子邮件中添加附件可以有人帮助我
答案 0 :(得分:0)
只需在主题下添加以下代码:
.AddAttachment "C:\****\*****\testfile.txt"
尝试以下
Dim oAttch As MailAttachment = New MailAttachment("C:\myattachment.zip")
然后在主题下添加以下内容:
.Attachments.Add(oAttch)
抱歉,上述内容对你不起作用......
我不使用办公室......
以下是适用于我的代码:
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "from@email.co.za"
objEmail.To = "to@email.co.za"
objEmail.Subject = "Attachment"
objEmail.Textbody = "Email with attachment"
objEmail.AddAttachment "C:\*******\*****\testfile.txt"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"mail.your_server.co.za"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objEmail.Configuration.Fields.Update
objEmail.Send
我不知道这对你有用吗</ p>