Solved

Outlook 2007 Macro: Move Exchange messages On Exit

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
outlook 6 48
outlook 15 44
Windows and Outlook 2013: Popup alert on mail to certain folder? 2 22
ost file to pst 10 59
Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
Outlook Free & Paid Tools
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

746 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

8 Experts available now in Live!

Get 1:1 Help Now