Vba Excel中的硬编码电子邮件地址
下面是一个简单的代码,它将使用任何打开的电子邮件程序发送电子邮件。我的问题是,我想在列表中添加三封电子邮件,但outlook 2013仅在我有一个地址时才能识别。 outlook的正确格式是什么?Vba Excel中的硬编码电子邮件地址,vba,excel,outlook,Vba,Excel,Outlook,下面是一个简单的代码,它将使用任何打开的电子邮件程序发送电子邮件。我的问题是,我想在列表中添加三封电子邮件,但outlook 2013仅在我有一个地址时才能识别。 outlook的正确格式是什么? Application.Dialogs(xlDialogSendMail).Show_ arg1:=”attributes@hotmail.ca", _ arg2:=“东属性”&Now() 我试过了 Application.Dialogs(xlDialogSendMail).Show_ arg1:=”
Application.Dialogs(xlDialogSendMail).Show_
arg1:=”attributes@hotmail.ca", _
arg2:=“东属性”&Now()
我试过了
Application.Dialogs(xlDialogSendMail).Show_
arg1:=”attributes@hotmail.ca" & ";" & "runaway@gmail.com", _
arg2:=“East attributes”&Now()。有关更多信息,请参阅
使用集合指定收件人、抄送收件人或密件抄送收件人。下面是一个关于如何从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
屏幕截图:
为什么不使用Outlook对象模型?此代码曾用于groupwise电子邮件系统,但现在我们已更改为Outlook。我知道我错发了Hotmail,但这不是答案。我想我可以用outlook的格式来修改原始版本,但这并不能真正回答我的问题。为什么不使用Outlook对象?我不熟悉Outlook对象模型,但我会查找它。谢谢我尝试了收件人集合代码,但它没有将姓名放入收件人:地址框中。这看起来很不错。我会尝试一下。ThanksIt用于发送电子邮件,但不包括附件。I=LBound(myfilelist)等下的行是否为“对不起,我的错误”。我已经评论了这句话。应该是评论吗?