【发布时间】:2021-03-19 16:43:15
【问题描述】:
我正在使用 Outlook 2010,并尝试根据附件名称将电子邮件转发给特定用户。下面的代码有效,除了我必须在 Outlook 中为每个不同的附件名称创建一个规则(即使在交换控制台中将规则大小增加到 256kb 后,我的规则最终也会耗尽存储空间)。
我希望这个脚本在一个规则下运行。它需要类似于....如果附件名称是“xxxxx.pdf”然后发送到“name@domain.com”如果不是然后跳过,如果附件名称是“xx.xls”然后发送到“ name1@domain.com" 如果没有则跳过....等等...
以下是我目前所拥有的,我希望将它们结合起来。
在 Outlook 会话中粘贴的代码:
Sub SendOnMessage23(olItem As MailItem)
Dim olAtt As Attachment, yest As Boolean, ol_newmail As MailItem
For Each olAtt In olItem.Attachments
If InStr(1, olAtt.FileName, "Print_Ack_Rpt.rpt_1100023-1") > 0 Then yest = True: Exit For
NextIf yest = True Then
Set ol_newmail = olItem.Forward
ol_newmail.To = "user@domain.com"
ol_newmail.Send
End If
End Sub
Sub SendOnMessage23(olItem As MailItem)
Dim olAtt As Attachment, yest As Boolean, ol_newmail As MailItem
For Each olAtt In olItem.Attachments
If InStr(1, olAtt.FileName, "Print_Ack_Rpt.rpt_1100024-1") > 0 Then yest = True: Exit For
NextIf yest = True Then
Set ol_newmail = olItem.Forward
ol_newmail.To = "user1@domain.com"
ol_newmail.Send
End If
End Sub
Sub SendOnMessage23(olItem As MailItem)
Dim olAtt As Attachment, yest As Boolean, ol_newmail As MailItem
For Each olAtt In olItem.Attachments
If InStr(1, olAtt.FileName, "Print_Ack_Rpt.rpt_1100024-1") > 0 Then yest = True: Exit For
NextIf yest = True Then
Set ol_newmail = olItem.Forward
ol_newmail.To = "user2@domain.com"
ol_newmail.Send
End If
End Sub
Sub SendOnMessage23(olItem As MailItem)
Dim olAtt As Attachment, yest As Boolean, ol_newmail As MailItem
For Each olAtt In olItem.Attachments
If InStr(1, olAtt.FileName, "Print_Ack_Rpt.rpt_1100024-1") > 0 Then yest = True: Exit For
NextIf yest = True Then
Set ol_newmail = olItem.Forward
ol_newmail.To = "user3@domain.com"
ol_newmail.Send
End If
End Sub
【问题讨论】: