【问题标题】:How to update a Sender EmailAddress如何更新发件人电子邮件地址
【发布时间】:2020-06-25 15:37:27
【问题描述】:

我正在代表共享邮箱 - 通用系统帐户发送电子邮件?

如何更新 Outlook 邮件中的发件人?

我收到运行时错误“438”:对象不支持此属性或方法。From = "MYACCOUNT@ACCOUNT.com"

Function CreateEmail(MySQL As String)
'On Error GoTo Exit_Function:
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem 'rs As Recordset

Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset(MySQL)
If rs.RecordCount > 0 Then
    rs.MoveFirst
    Do Until rs.EOF
    If IsNull(rs!standard_e_mail_addr) Then
        rs.MoveNext
    Else
        If oOutlook Is Nothing Then
            Set oOutlook = New Outlook.Application
        End If
        Set oEmailItem = oOutlook.CreateItem(olMailItem)
        With oEmailItem
            .To = rs!standard_e_mail_addr
            .From = "MYACCOUNT@ACCOUNT.com" ' **
            .Subject = "Mandatory Action Required Submit In-Person Identification Form for " & rs!emp_fname
            .Body = "EmpNo: " & rs!emp_no & vbCr & _
                    "EmpName: " & rs!emp_fname & vbCr & _
                    "DO NOT REPLY."

            .Display
            .Send
             rs.Edit
             rs!EmailNotification_Send = Date
             rs.Update

        End With
        Set oEmailItem = Nothing
        Set oOutlook = Nothing
        rs.MoveNext
End If
Loop

Else
End If
rs.Close
Exit Function:
    Exit Function
End Function

【问题讨论】:

标签: vba ms-access outlook


【解决方案1】:

好的,试试:.SentOnBehalfOfName = """SenderName"" <MyAccount@Address.com>"

还评论:Use another account for sender

【讨论】:

  • 您的链接已损坏。尝试提供您使用或查看过的页面/论坛/问题的答案和参考。
  • 抱歉,复制/粘贴搞砸了。固定链接。
【解决方案2】:

首先,在调用Send方法之前不需要调用Display

如果您在 Outlook 中配置了共享邮箱,则需要使用 SendUsingAccount 属性,该属性允许设置一个 Account 对象,该对象表示要发送 MailItem 的帐户。例如:

Sub SendUsingAccount() 
  Dim oAccount As Outlook.account  
  For Each oAccount In Application.Session.Accounts  
    If oAccount.AccountType = olPop3 Then  
      Dim oMail As Outlook.MailItem  
      Set oMail = Application.CreateItem(olMailItem)  
      oMail.Subject = "Sent using POP3 Account"  
      oMail.Recipients.Add ("someone@example.com")  
      oMail.Recipients.ResolveAll  
      oMail.SendUsingAccount = oAccount  
      oMail.Send  
    End If  
  Next  
End Sub 

使用SentOnBehalfOfName只要你的Exchange账户对共享邮箱或通讯组有SendAs权限,就会从共享账户或组发送,不代表发送。

    With oEmailItem
        .To = rs!standard_e_mail_addr
        .SentOnBehalfOfName = "MYACCOUNT@ACCOUNT.com" 
        .Subject = "Mandatory Action Required Submit In-Person Identification Form for " & rs!emp_fname
        .Body = "EmpNo: " & rs!emp_no & vbCr & _
                "EmpName: " & rs!emp_fname & vbCr & _
                "DO NOT REPLY."
        .Send

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-21
    • 2017-07-21
    • 2012-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多