以下是一个简单的代码,可以使用任何打开的电子邮件程序发送电子邮件。我的问题是我想在列表中添加三封电子邮件,但是如果我有一个地址,outlook 2013只能识别它。
outlook的正确格式是什么?
Application.Dialogs(xlDialogSendMail).Show _
arg1:="attributes@hotmail.ca", _
arg2:="East attributes" & Now()
我试过了
Application.Dialogs(xlDialogSendMail).Show _
arg1:="attributes@hotmail.ca" & ";" & "runaway@gmail.com", _
arg2:="East attributes" & Now()
答案 0 :(得分:1)
以下是如何从Excel自动化Outlook的一个非常基本的示例。请注意我使用的是LateBinding。
Option Explicit
Sub Sample()
Dim OutApp As Object
Dim OutMail As Object
Dim MyFileList(1) As String
Dim i As Long
'~~> Change/Add the file names here
MyFileList(0) = "C:\Sample1.xlsx"
MyFileList(1) = "C:\Sample2.xlsx"
'~~> Create a new instance of outlook
Set OutApp = CreateObject("Outlook.Application")
'~~> Create a new Email
Set OutMail = OutApp.CreateItem(0)
'~~> Set the To/CC/BCC etc here
With OutMail
.To = "MyEmail1@123.com" & ";" & "MyEmail2@123.com" & ";" & "MyEmail3@123.com"
.CC = "MyEmail4@123.com"
.Bcc = "MyEmail5@123.com"
.Subject = "Example for attaching 2 files"
.Body = "Hi Russel :)"
'~~> Attaching file
For i = LBound(MyFileList) To UBound(MyFileList)
.Attachments.Add MyFileList(i)
Next i
'~~> Display the email. To send the email, Change the below to .Send
.Display
End With
End Sub
<强>截图强>:
答案 1 :(得分:0)
您可以从Excel自动执行Outlook以完成工作。有关详细信息,请参阅How to automate Outlook from another program。
使用Recipients集合指定收件人,抄送或密送收件人。