我正在尝试编写一个宏,允许我从共享邮箱中回复电子邮件。我尝试了以下操作,但是当我发送电子邮件时,它总是从活动邮箱发送,而不是从共享邮箱发送。您是否知道我在代码中哪里出错了?
Public Sub ForwardwithCC()
Dim strRecip As String
Dim objMsg, oMail As MailItem
Set objMsg = ActiveExplorer.Selection.Item(1).Forward
If TypeName(ActiveExplorer.Selection.Item(1)) = "MailItem" Then
Set oMail = ActiveExplorer.Selection.Item(1)
On Error Resume Next
For Each Recipient In oMail.Recipients
strRecip = Recipient.Address & ";" & strRecip
Next Recipient
objMsg.CC = strRecip & ";" & oMail.SenderEmailAddress
objMsg.BCC = "ActiveAdress@test.com"
objMsg.Recipients.ResolveAll
For Each Recipient In objMsg.Recipients
If (Recipient.Name) = "ActiveAdress" Then
Recipient.Delete
End If
Next Recipient
objMsg.SentOnBehalfOfName = "AdressToBeUsed@test.com"
objMsg.Display
Else
End If
Set objMsg = Nothing
End Sub
非常感谢您对此事的看法
编辑:
由于找不到适合使用.forward或.reply的解决方案,并且在此过程的前面我注意到,SentonBehalfOfName在创建新电子邮件时正在工作,因此我采用了完全不同的策略。
创建一个答复集并将其存储为变量 创建一个新电子邮件,复制收件人和答复者的主题 复制回复邮件的正文 SendOnBehalfOfName
完美运行。谢谢大家的帮助。