开发者

Outlook AddOn How to get selected emails?

I'm making an outloo开发者_JAVA技巧k addon and I'm trying to find a way to see which emails are selected, then be able to work with them through a foreach (or whatever). If this is not possible, is there a way to fetch all items in a folder and get access to that information easily? After that I need to move those items to another folder.

How would I go about doing this?


You can use the Application.ActiveExplorer method to get the currently active Explorer window (= the thing that displays the list of mails). Then you can use the Explorer.Selection property to obtain the list of selected e-mails.

To move the mails, use the MailItem.Move method.


Attached is my code to get the selected email from outlook messages. For the olitem feel free to modify as you need.

Sub ReplyMSG()
    Dim olItem As Outlook.MailItem
    Dim olReply As MailItem  ' Reply
    For Each olItem In Application.ActiveExplorer.Selection
        Set olReply = olItem.ReplyAll
        olReply.HTMLBody = "Reminder" & vbCrLf & olReply.HTMLBody
        olReply.Display
        'olReply.Send
    Next olItem
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜