【问题标题】:Sending outlook emails from Excel从 Excel 发送 Outlook 电子邮件
【发布时间】:2018-07-24 18:58:48
【问题描述】:

我有以下 VBA 可以很好地发送电子邮件:

    With Sendrng

        ' Select the worksheet with the range you want to send
        .Parent.Select

        'Remember the ActiveCell on that worksheet
        Set rng = ActiveCell

        'Select the range you want to mail
        .Select

        ' Create the mail and send it
        ActiveWorkbook.EnvelopeVisible = True
        With .Parent.MailEnvelope

            ' Set the optional introduction field thats adds
            ' some header text to the email body.
            .Introduction = ""

            With .Item
                .To = "123@321.com"
                .CC = ""
                .BCC = ""
                .Subject = "A new deli pre-order has been received."
                .Send
            End With

我现在苦苦挣扎的部分是设置电子邮件来自谁

我认为添加以下内容会起作用:

 .From = "111@222.com"

添加上述内容时会发生什么: 根本收不到邮件

我错过了什么?

【问题讨论】:

    标签: excel excel-2010 excel-2007 vba


    【解决方案1】:

    您可以尝试.SendUsingAccount 选择您要发送电子邮件的帐户。

    With .Item
        .SendUsingAccount = olAccount 'or some other account.
        .To = "123@321.com"
        .CC = ""
        .BCC = ""
        .Subject = "A new deli pre-order has been received."
        .Send
    End With
    

    【讨论】:

      【解决方案2】:

      您可能正在寻找.SenderEmailAddress.SentOnBehalfOfName

      【讨论】:

      • 谢谢 - 也试过了,但没有收到任何电子邮件
      【解决方案3】:

      试试这个方法。

      Sub Mail_workbook_Outlook_1()
      'Working in Excel 2000-2016
      'This example send the last saved version of the Activeworkbook
      'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
          Dim OutApp As Object
          Dim OutMail As Object
      
          Set OutApp = CreateObject("Outlook.Application")
          Set OutMail = OutApp.CreateItem(0)
      
          On Error Resume Next
          With OutMail
              .to = "ron@debruin.nl"
              .CC = ""
              .BCC = ""
              .Subject = "This is the Subject line"
              .Body = "Hi there"
              .Attachments.Add ActiveWorkbook.FullName
              'You can add other files also like this
              '.Attachments.Add ("C:\test.txt")
              .Send   'or use .Display
          End With
          On Error GoTo 0
      
          Set OutMail = Nothing
          Set OutApp = Nothing
      End Sub
      

      https://www.rondebruin.nl/win/s1/outlook/amail1.htm

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-01-18
        • 1970-01-01
        • 2010-09-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多