Macro to move mail item

  • Thread starter Thread starter Robin
  • Start date Start date
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
 
I just want to create a macro that will move the currently highlighted mail
item to a specified folder. Thanks
 
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
 
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
 
Back
Top