Email 向定期outlook电子邮件vbs添加附件

Email 向定期outlook电子邮件vbs添加附件,email,vbscript,outlook,recurring,Email,Vbscript,Outlook,Recurring,首先,我不是一个真正的程序员,几乎无法完成这项工作 我想用outlook发送一封定期电子邮件,所以我用谷歌搜索了一下,找到了我在记事本中写的这个脚本,然后将它保存在.vbs中,邮件的正文使用HTML,之后我使计划任务成为自动的。 这对我来说真的很好,但现在我想在这封邮件中添加一个附件,我努力搜索,但没有找到任何可以使用这个脚本的东西,而且最大的问题是,大多数时候我什么都不懂,所以我希望如果有人能帮我,这就是我使用的脚本 Dim olkApp Dim olkSes Dim olkMsg Set o

首先,我不是一个真正的程序员,几乎无法完成这项工作

我想用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

我想在这封电子邮件中添加附件。有人能帮我吗?

只需在主题下方添加以下代码即可:

.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

我不知道这是否适用于您

我尝试了您的解决方案,但出现了错误,对象不支持此属性或方法:“AddAttachment”,我的附件是jpg,这是导致错误的原因还是它可以处理任何文件类型我很抱歉报告仍然不工作我尝试发送txt和jpg,并将文件直接放入c:那么你有其他解决方案吗我很感激这个脚本可以处理outlook,如果你能告诉我每行的用途,我可以在邮件正文中使用HTML吗是的,这在没有outlook的情况下有效,您可以在正文中使用HTML。您必须将发件人、更改为电子邮件地址。您需要将smtpserver更改为传出邮件服务器,并插入正确的用户名和密码。如果您的邮件服务器不需要身份验证,则需要将smtpauthenticate设置为2,您还可以查看