Solved

Outlook 2007 Macro: Move Exchange messages On Exit

Posted on 2009-05-13
3
253 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now