我有一个特定用户真的希望能够将任何电子邮件重定向到他们部门中的其他人,这样当该人回复该电子邮件时,它将返回给最初发送该电子邮件的人。
我们不能授予他们作为所有人发送的权限,因为并非所有用户都是内部的,所以我试图让一个VBScript在Outlook中运行,它将向前发送指定文件夹中的所有电子邮件,但更改回复地址以便他们不必每次都手动放入。
我对VB脚本相当新,所以它可能是我缺少的基本内容。
这是我正在尝试的但它不起作用:
Sub SendFolder()
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim MyFolder As Outlook.MAPIFolder
Dim ObjMail As Outlook.MailItem
Set olApp = Outlook.Application
Set olNS = olApp.GetNamespace("MAPI")
Set MyFolder = Application.Session.Folders("me@us.com").Folders("test")
For i = MyFolder.Items.Count To 0 Step -1
Set ObjMail.Subject = MyFolder.Itmes(i).Subject
Set ObjMail.ReplyRecipients = MyFolder.Itmes(i).ReplyRecipients
Set ObjMail.Body = MyFolder.Itmes(i).Body
Set ObjMail.Attachments = MyFolder.Itmes(i).Attachments
Set ObjMail.BodyFormat = MyFolder.Itmes(i).BodyFormat
Set ObjMail.To = "test@us.com"
ObjMail.Send
Next
End Sub
答案 0 :(得分:2)
你错过了
设置ObjMail = Application.CreateItem(olMailItem)
然后你的代码就会变成
With ObjMail
.Subject = MyFolder.Itmes(i).Subject
.ReplyRecipients = MyFolder.Items(i).ReplyRecipients
.Body = MyFolder.Items(i).Body
.Attachments = MyFolder.Items(i).Attachments
.BodyFormat = MyFolder.Items(i).BodyFormat
.To = "test@us.com"
.Send
End with
它现在运行,ReplyTo不会改变。
您需要设置ObjMail的ReplyRecipients属性
像.ReplyRecipients.Add MyFolder.Items(i).SenderEmailAddress
要简化问题,请按原样转发邮件,并仅设置ReplyRecipients属性。
查看此替代方案。邮件作为附件发送。接收方自动回复原始发件人。
<强>未测试强>
Sub SendFolderItemsAsAttachments()
' Run this VBA code while in Outlook
Dim MyFolder As MAPIFolder
Dim notMyItems as Items
Dim notReplyingToMe as mailitem
Dim i as long
Set MyFolder = Application.Session.Folders("me@us.com").Folders("test")
Set notMyItems = MyFolder.Items
For i = notMyItems.Count To 1 Step -1
If TypeOf notMyItems(i) Is MailItem Then
Set notReplyingToMe = Application.CreateItem(olMailItem)
With notReplyingToMe
.Subject = notMyItems(i).Subject & " - " & _
notMyItems(i).SenderName
.HTMLBody = "Redirecting for your action."
.Attachments.Add notMyItems(i), olEmbeddeditem
.To = "test@us.com"
.Send
End With
notMyItems(i).Delete
End If
Next
Set MyFolder = = Nothing
Set notMyItems = Nothing
Set notReplyingToMe = Nothing
End Sub