Solved

Outlook 2007 Macro: Move Exchange messages On Exit

Posted on 2009-05-13
3
258 Views
Last Modified: 2012-05-06
Hello,

Please help me modify the code below to accept messages within my Exchange 2003 environment itself (i.e. from an Exchange email account to my Exchange email account). The current scenario accepts external SMTP messages only.

Thank you
Sub CRBQuit()
Const The_MailAccount_Name = "fred@fred.com"
Dim obj As Object
Dim mai As mailitem
Dim destFolder As Outlook.Folder
 
    Set destFolder = Application.Session.GetDefaultFolder(olFolderInbox).folders("experts Exchange")
    For Each obj In Application.Session.GetDefaultFolder(olFolderInbox).items
        If obj.Class = olMail Then
            Set mai = obj
            If mai.SenderEmailAddress = The_MailAccount_Name Then
                mai.Move destFolder
            End If
        End If
    Next
End Sub

Open in new window

0
Comment
Question by:maherusa
  • 2
3 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 24382203
It is a matter of either:

Changing the mail address format to that of your server or adding an additional function to derive the SMTP address.

First option:

Try selecting an email from an internal address in the explorer, (don't open it though) then in teh VBE type in the immediate window, (ctrl + G to display it):

?application.activeexplorer.selection(1).senderemailaddress. and armed with this information we can edit the process to cater for both internal and external  addresses.

Chris
0
 

Author Comment

by:maherusa
ID: 24405111
Thanks Chris for the reply, but Ctrl+G didn't result in anything... I may also have not used the command correctly. Can you please give me more instructions on how to get the address using this shortcut?

Thanks.
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 24405122
ctrl + G is a switch on it doesn't toggle so it merely ensures the immediate window is visible.

The window in the VBE is titled as "Immediate", and put the cursor therein and with the email selected but not open paste then enter the following:

?application.activeexplorer.selection(1).senderemailaddress

CChris
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question