![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi. I have a macro (generously donated by Ken) which I have adapted to move a
throw-away email that I am sending to a temporary folder. The line: objInbox.Folders("Temp Sent") does the job, but the folder is not in the right place. I would like this Temp Sent folder to be a subfolder to the standard Sent Items folder. Any ideas on the change to the syntax? Thanks. |
#2
|
|||
|
|||
![]()
Dim oSent As Outlook.MAPIFolder
Set oSent = oNS.GetDefaultFolder(olFolderSentMail) oSent.Folders("Temp Sent") Of course you have to create that folder there before the code will work. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Robin" wrote in message ... Hi. I have a macro (generously donated by Ken) which I have adapted to move a throw-away email that I am sending to a temporary folder. The line: objInbox.Folders("Temp Sent") does the job, but the folder is not in the right place. I would like this Temp Sent folder to be a subfolder to the standard Sent Items folder. Any ideas on the change to the syntax? Thanks. |
#3
|
|||
|
|||
![]()
Thanks Ken! The procedure works great on new emails, but I now have a problem
with "reply" and "forward" emails (very strange!). An error message comes up: "Send operation failed because item was deleted before it was sent". Any ideas? My code so far: Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim answer As Long Dim objFolder As Outlook.MAPIFolder Dim oSent 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 oSent = objNS.GetDefaultFolder(olFolderSentMail) Set objFolder = oSent.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 oSent = Nothing Set objNS = Nothing Item.DeleteAfterSubmit = True End If End If End Sub "Ken Slovak - [MVP - Outlook]" wrote: Dim oSent As Outlook.MAPIFolder Set oSent = oNS.GetDefaultFolder(olFolderSentMail) oSent.Folders("Temp Sent") Of course you have to create that folder there before the code will work. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Robin" wrote in message ... Hi. I have a macro (generously donated by Ken) which I have adapted to move a throw-away email that I am sending to a temporary folder. The line: objInbox.Folders("Temp Sent") does the job, but the folder is not in the right place. I would like this Temp Sent folder to be a subfolder to the standard Sent Items folder. Any ideas on the change to the syntax? Thanks. |
#4
|
|||
|
|||
![]()
You can't move an item in ItemSend or you get the error you're getting.
In this case I'd not do that but instead I'd set SaveSentMessageFolder: Set Item.SaveSentMessageFolder = objFolder That will save the item when the send is complete to the designated folder automatically with no further intervention from you. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Robin" wrote in message ... Thanks Ken! The procedure works great on new emails, but I now have a problem with "reply" and "forward" emails (very strange!). An error message comes up: "Send operation failed because item was deleted before it was sent". Any ideas? My code so far: Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim answer As Long Dim objFolder As Outlook.MAPIFolder Dim oSent 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 oSent = objNS.GetDefaultFolder(olFolderSentMail) Set objFolder = oSent.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 oSent = Nothing Set objNS = Nothing Item.DeleteAfterSubmit = True End If End If End Sub |
#5
|
|||
|
|||
![]()
Thanks a lot, Ken, that seems to work perfectly now. Just to confirm: I
replaced Item.DeleteAfterSubmit = True with Set Item.SaveSentMessageFolder = objFolder. Regards, Robin. "Ken Slovak - [MVP - Outlook]" wrote: You can't move an item in ItemSend or you get the error you're getting. In this case I'd not do that but instead I'd set SaveSentMessageFolder: Set Item.SaveSentMessageFolder = objFolder That will save the item when the send is complete to the designated folder automatically with no further intervention from you. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Robin" wrote in message ... Thanks Ken! The procedure works great on new emails, but I now have a problem with "reply" and "forward" emails (very strange!). An error message comes up: "Send operation failed because item was deleted before it was sent". Any ideas? My code so far: Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim answer As Long Dim objFolder As Outlook.MAPIFolder Dim oSent 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 oSent = objNS.GetDefaultFolder(olFolderSentMail) Set objFolder = oSent.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 oSent = Nothing Set objNS = Nothing Item.DeleteAfterSubmit = True End If End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Rules duplicating email instead of moving | Bob Levine | Outlook - General Queries | 5 | November 4th 06 02:32 PM |
moving contacts list to the tool bar and to: on new email | Frank T | Outlook - Using Contacts | 2 | August 17th 06 04:56 PM |
Moving Outlook to another PC, and moving data files to another location | /mel/ | Outlook - General Queries | 3 | June 24th 06 04:39 PM |
Moving Specific Inbox Items to a Specific Subfolder (VBA) | DevDaniel | Outlook and VBA | 1 | April 11th 06 06:46 AM |
MOVING EMAIL BETWEEN DRIVES | IDIDIT | Outlook - General Queries | 1 | January 30th 06 03:49 AM |