Macro to move mail item

R

Robin

Public Sub movetosave()

Ok, I posted a little while ago about a rule to move mail items and I've
kind of given up on that and am trying something else. I'm trying to write
VB code to use as a macro and don't know what I'm doing. This is what I've
been able to come up with from picking through the help info and all I get
is an error message that says 'object required'. Can someone tell me what
I'm doing wrong?

thanks

Public Sub mocetosave()
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myitems = myInbox.Items
Set myDestFolder = myInbox.Folders("Saved Mail")
Set myitem = myitems.CurrentItem
myitem.MoveTo myDestFolder
End Sub
 
R

Robin

I just want to create a macro that will move the currently highlighted mail
item to a specified folder. Thanks
 
S

Sue Mosher [MVP-Outlook]

Try this:

Public Sub mocetosave()
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myitems = myInbox.Items
Set myDestFolder = myInbox.Folders("Saved Mail")
Set myitem = GetCurrentItem()
myitem.MoveTo myDestFolder
End Sub

GetCurrentItem is a function available from
http://www.outlookcode.com/codedetail.aspx?id=50
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
R

Robin

Thanks!! I appreciate the info!
Sue Mosher said:
Try this:

Public Sub mocetosave()
Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(6)
Set myitems = myInbox.Items
Set myDestFolder = myInbox.Folders("Saved Mail")
Set myitem = GetCurrentItem()
myitem.MoveTo myDestFolder
End Sub

GetCurrentItem is a function available from
http://www.outlookcode.com/codedetail.aspx?id=50
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top