How To Take A Reference Of A Mail After Moving The Mail To A Different Folder

kashif.special2005

Active Member
Joined
Oct 26, 2009
Messages
443
Hi,
I hope all of you are doing good and staying safe and healthy, I want your expert help on a problem that I am facing in Excel VBA code:

I have a mail in outlook and through "Move" method I am moving this mail to a different folder, now what I want is that I want to take a reference of this mail from the moved folder.

Suppose "A" is a folder where have a mail and I want to move this mail to the folder "B", through below code I am moving this mail from folder "A" to folder "B".

set MyNameSpace=Outlook.Application.GetNamespace("MAPI")
Set Mymail=ActiveExplorer.Selection.Item(1)
Set B = MyNameSpace.folders("Inbox").folders("B")
Mymail.Move B

Now, after moving the mail in the folder "B" I want to take the reference of this mail from the folder "B".

I don't know how to do this, my kind request to you please help me how can I do this.

Thanks in advance for your help.

Thanks
Kashif
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The Move method/function returns a reference to the destination object (a MailItem in this case):

Code:
Function Move(DestFldr As Folder) As Object

Therefore:
VBA Code:
    Dim emailInB As Outlook.MailItem
    Set emailInB = Mymail.Move(B)
    MsgBox "The email is now in " & emailInB.Parent.FolderPath
 
Upvote 0
The Move method/function returns a reference to the destination object (a MailItem in this case):

Code:
Function Move(DestFldr As Folder) As Object

Therefore:
VBA Code:
    Dim emailInB As Outlook.MailItem
    Set emailInB = Mymail.Move(B)
    MsgBox "The email is now in " & emailInB.Parent.FolderPath
Thank you so much Jowh_w you code is working like a charm, thank you thank you again, God bless you.

Thanks
Kashif
 
Upvote 0

Forum statistics

Threads
1,225,155
Messages
6,183,206
Members
453,151
Latest member
Lizamaison

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top