Outlook VBA宏“复制”来电邮箱 [英] Outlook VBA macro to "copy" incoming email
问题描述
我正在寻找代码将所有传入的电子邮件发送到我的Outlook电子邮件并复制到我的gmail帐户。我最初有一个脚本来查找所有电子邮件,但更改电子邮件地址是一个很大的痛苦,然后fwd信息在身体等等。
最后,我想要一个脚本复制到另一个没有fwd的电子邮件(或者至少保留它来自原始发件人而不是来自我的所有内容)并且能够将我的gmail帐户中的电子邮件标记为已读取通过展望(或两种方式,如果可能的话)
谢谢!
I am looking for code to take all incoming emails to my outlook email and "copy" to my gmail acct. I originally had a script to fwd all emails, but it's a major pain to change the email address, and then the fwd info is in the body, etc. etc.
Ultimately, I would like a script to copy to another email without the fwd (or at least keeping it from the original sender instead of everything being from me) and be able to mark the email as read in my gmail acct if I read it through outlook (or both ways if that's possible)
thank you!
推荐答案
根据bigazonk的评论总结讨论...
可能不可能发送电子邮件作为另一个人。为什么?请参阅:代表其他人发送电子邮件 [ ^ ]
唯一的方法是转发邮件。;(
原始转发的示例宏,假设该人有权发送邮件代表其他人,应该看起来像:
Summarizing the discussion based on bigazonk's comments...
There is probably not possible to send email as another person. Why? See this: Send an e-mail message on behalf of someone else[^]
The only way is to forward a mail message. ;(
Example macro for "original forwarding", assuming that person has a permission to send mail on behalf of someone else, should looks like:
Option Explicit
Sub PushMailToMe()
Dim srcMi As MailItem, dstMi As MailItem
Dim fld As Folder, att As Attachment
On Error GoTo Err_PushMailToMe
Set fld = Application.Session.GetDefaultFolder(olFolderInbox)
For Each srcMi In fld.Items
If srcMi.UnRead = False Then GoTo SkipMail
Set dstMi = Application.CreateItem(olMailItem)
With dstMi
.Sender = srcMi.Sender
.Subject = srcMi.Subject
.To = "mymail@domain.com"
.CC = srcMi.CC
.BodyFormat = olFormatHTML
.HTMLBody = srcMi.HTMLBody & vbCrLf & vbCrLf & "Original forwarding by PushMailToMe (year: 2013)"
For Each att In srcMi.Attachments
.Attachments.Add att
Next
.Send
End With
SkipMail:
Next
Exit_PushMailToMe:
On Error Resume Next
Set srcMi = Nothing
Set dstMi = Nothing
Exit Sub
Err_PushMailToMe:
MsgBox Err.Description, vbExclamation, Err.Number
Resume Exit_PushMailToMe
End Sub
干杯!
Maciej Los
[/ EDIT]
Cheers!
Maciej Los
[/EDIT]
这篇关于Outlook VBA宏“复制”来电邮箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!