宏转发电子邮件拖入Outlook子文件夹 [英] Macro to forward emails dragged into an outlook subfolder

查看:93
本文介绍了宏转发电子邮件拖入Outlook子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我解决以下问题


我的Outlook邮箱中有一个子文件夹。将电子邮件拖入子文件夹后,电子邮件应转发到固定的电子邮件帐户。实际的电子邮件应该移动到另一个子文件夹。



这可能吗?如果是这样,有没有人可以解释一下?

解决方案

在Outlook中可以通过文件夹访问文件夹NameSPace.In的对象我假设一个子文件夹名称Dec


打开Visual Basic - (来自Tools-> Macro)


创建一个新类模块来自Insert> Class Module并将其重命名为"clsOutlook"。并在其下面粘贴代码。

 Dim ns As NameSpace 
Public WithEvents MyItems As Outlook.Items

Private Sub MyItems_ItemAdd(ByVal Item As Object)

Dim MI As MailItem
Dim MIFwd As MailItem

设置MI =项目

设置ns = Application.GetNamespace(" MAPI")
设置MIFwd = MI.Forward

使用MIFwd
.Recipients .Add(" John")。Type = olTo
。保存
。显示
'您可以忽略显示并让邮件为
'sa草稿文件夹中的ved
结束时

结束次级




然后点击Project-> Microsoft Outlook Objects-> Thisoutlooksession并粘贴以下代码

 Dim MyClass As new clsOutLook 
Private Sub Application_Startup()
Dim ns As NameSpace
Set ns = Application.GetNamespace(" MAPI")
Set MyClass.MyItems = ns.Folders(" Personal Folders" ;)。文件夹("Z-Old Mail")。文件夹("Dec")。项目
结束次级

路径文件夹将是您邮箱的差异。在Mycase中它是Z-Old Mail / Dec.After粘贴后关闭Outlook并重新启动。重启后你会看到你想要的东西。


我没有给出任何移动代码。你可以很容易包括在sub的底部  MyItems_ItemAdd如下


MI.Move fldYourTrgetFolder。




Can some one help me with the below requirement

I have a subfolder in my outlook mailbox. Once i drag an email into the subfolder, the email should be forwarded to a fixed email account. The actual email should be moved to another subfolder.

Is this possible? If so, could any one please explain how?

解决方案

In outlook the folders are accessible through folder object of NameSPace.In below I assumed a subfolder name Dec

Open Visual Basic -(from Tools->Macro)

Create a new Class Module from Insert>Class Module and rename it to "clsOutlook".And paste below code there.

Dim ns As NameSpace
Public WithEvents MyItems As Outlook.Items

Private Sub MyItems_ItemAdd(ByVal Item As Object)
    
    Dim MI As MailItem
    Dim MIFwd As MailItem
        
    Set MI = Item
       
    Set ns = Application.GetNamespace("MAPI")
    Set MIFwd = MI.Forward
    
    With MIFwd
       .Recipients.Add("John").Type = olTo
       .Save
       .Display
       'You can ignore the Display and let the mail be
       'saved in draft folder
    End With
    
End Sub


Then click the Project->Microsoft Outlook Objects->Thisoutlooksession and paste the below code

Dim MyClass As New clsOutLook
Private Sub Application_Startup()
        Dim ns As NameSpace
        Set ns = Application.GetNamespace("MAPI")
        Set MyClass.MyItems = ns.Folders("Personal Folders").Folders("Z-Old Mail").Folders("Dec").Items
End Sub

The path of folder will be diff for your mailbox. In Mycase it is Z-Old Mail/Dec.After pasting shut the Outlook and restart.After restart you see what you want.

I have not given any code for moving.You can easily include at bottom of sub  MyItems_ItemAdd like below

MI.Move fldYourTrgetFolder.


这篇关于宏转发电子邮件拖入Outlook子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆