我代表共享邮箱发送电子邮件 - 通用系统帐户?
如何在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
答案 0 :(得分:0)
好的,请尝试:.SentOnBehalfOfName = """SenderName"" <MyAccount@Address.com>"
答案 1 :(得分:0)
首先,在调用Display
方法之前无需调用Send
。
如果您在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
只要您的Exchange帐户具有共享邮箱或通讯组的SendAs权限,就使用SentOnBehalfOfName,它将从共享帐户或组发送,而不是代表发送。
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