A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

create a macro to move outlook 2003 message to a specific fold



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 4th 07, 12:09 PM posted to microsoft.public.outlook.program_vba
robin
external usenet poster
 
Posts: 53
Default create a macro to move outlook 2003 message to a specific fold

Hey Eric
I had a look at this post and I have modified the code to move an email that
I am sending into a temporary folder if I dont think that I will need. It
works fine on a new email but for forwarded mails (go figure!) gives an error
message "The Send operation failed because the item was deleted before it was
sent". It does send the mail to the "TEMP SENT" folder though. Any ideas what
is causing this? My code:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim answer As Long
Dim objFolder As Outlook.MAPIFolder, objInbox As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace

If Item.Class = olMail Then
answer = MsgBox("SAVE subj: " & Item.Subject & " to Sent Items?", vbYesNo)
If answer = vbNo Then
On Error Resume Next
Set objNS = Application.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders("TEMP SENT")

If objFolder Is Nothing Then
MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation,
"INVALID FOLDER"
End If

If Application.ActiveInspector Is Nothing Then
'Require that this procedure be called for an open item
Exit Sub
End If

If Application.ActiveInspector.CurrentItem.Class olMail Then
Exit Sub
End If

Application.ActiveInspector.CurrentItem.Move objFolder

Set objFolder = Nothing
Set objInbox = Nothing
Set objNS = Nothing
End If
End If
End Sub

"Gus Darino" wrote:

Can you provide a variation of this macro that will move the emails to a
folder on a "personal folder" (PST) file instead?

Auto Archive lets me do this on a scheduled basis but I need to be able
to move emails manually. The solution you provided gets me there with
the adjustment above.

Thank you

GusDarino



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to create new email message with different account as sender Brian Beck Outlook and VBA 1 March 22nd 07 12:15 AM
Macro to open a new Task and assign it a specific category Steve Marshall Outlook and VBA 1 November 9th 06 07:01 AM
How ...When i move a message to a specific map... Ikku de Dikku Outlook - General Queries 3 September 21st 06 02:26 PM
Macro to foward just a specific part of an email body of message [email protected] Outlook and VBA 6 August 21st 06 10:07 PM
How do you set-up Outlook 2003 without the duplicate Personal Fold Sue Outlook - Installation 3 May 1st 06 12:11 AM


All times are GMT +1. The time now is 11:28 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.