我正在使用Outlook 2010,我試圖根據附件名稱將電子郵件轉發給特定用戶。下面的代碼工作,除了我必須在Outlook中爲每個不同的附件名稱創建一個規則(即使在交換控制檯中將規則大小增加到256kb後,我的規則最終也會用完存儲空間)。根據附件名稱轉發電子郵件
我想這個腳本運行在一個規則下。如果附件名稱是「xxxxx.pdf」,那麼它將需要類似....如果不是,則發送到「[email protected]」,然後跳過,如果附件名稱是「xx.xls」,則發送到「 [email protected]「如果不是那麼跳過....等等...
以下是我到目前爲止,我想這一切結合起來。
代碼在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 = "[email protected]"
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 = "[email protected]"
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 = "[email protected]"
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 = "[email protected]"
ol_newmail.Send
End If
End Sub
這工作完美。感謝您花時間清理並詳細解釋代碼! –