从不同的电子邮件帐户发送邮件

时间:2014-01-31 18:25:11

标签: vba outlook excel-2013

当我发送电子邮件时,他们会在工作时从我的个人收件箱中退出,但是我需要他们从我可以访问的另一个邮箱出去。我的Outlook中有两个邮箱。

我可以从特定邮箱发送电子邮件吗?

这是我正在使用的代码。它在我的帐户中找不到第二项。

 Sub Mail_small_Text_Change_Account()

    Dim cel As Range
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olMailItem)

    strbody = "Hi there" & vbNewLine & vbNewLine & _
          "This is line 1" & vbNewLine & _
          "This is line 2" & vbNewLine & _
          "This is line 3" & vbNewLine & _
          "This is line 4"

    On Error Resume Next

    For Each cel In Range(("C2"), Range("C2").End(xlDown))
        With OutMail
            .To = cel.Value
            '.CC = cel.Offset(0, 3).Value
            .Subject = "Benefits Refund"
            .Body = strbody
            .SendUsingAccount = OutApp.Session.Accounts.Item(2)
            .Send   'or use .Display
        End With

    Next

    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

1 个答案:

答案 0 :(得分:0)

是。使用POP邮箱,您可以指定任何帐户的用户名和密码。

.To = "E@E.com"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "This is the body"
.SendUsingAccount = OutApp.Session.Accounts.Item(1)
相关问题