Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Outlook 2007 Macro: Move Exchange messages On Exit

Posted on 2009-05-13
3
Medium Priority
?
265 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

610 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