![]() |
How to Add a MailItem to a Folder
I have created a folder called "Forwarded" and I am using this code:
Private Sub outApp_NewMailEx(ByVal EntryIDCollection As String) ' Dim oFolder As MAPIFolder ' Set oFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderInbo x) Dim arr() As String Dim i As Integer Dim m As MailItem On Error Resume Next arr = Split(EntryIDCollection, ",") For i = 0 To UBound(arr) Set m = Application.Session.GetItemFromID(arr(i)) m.To = " AddNewItemToFolder (m) m.Send Next End Sub Public Sub AddNewItemToFolder(oItem As MailItem) Dim oFolder As MAPIFolder Set oFolder = GetNamespace("MAPI").Folders.Item("Forwarded") oFolder.Items.Add (oItem) End Sub But Even though I have a breakpoint in AddNewItemToFolder, I never get there. It's as if the call to this subroutine were commented out. |
How to Add a MailItem to a Folder
Firstly, do not try to send a message that has already been received. Create
a new message (Application.CreateItem or MAPIFolder.Items.Add), populate its properties, then send, Secondly. Items.Add create a brand new item and takes either an OlItemType enum (e.g. olMailItem) or a string indicating teh desired message class (e.g. "IPM.Note"). If you want to move an existing item to a folder, use MailItem.Move(). Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "RON" wrote in message ... I have created a folder called "Forwarded" and I am using this code: Private Sub outApp_NewMailEx(ByVal EntryIDCollection As String) ' Dim oFolder As MAPIFolder ' Set oFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderInbo x) Dim arr() As String Dim i As Integer Dim m As MailItem On Error Resume Next arr = Split(EntryIDCollection, ",") For i = 0 To UBound(arr) Set m = Application.Session.GetItemFromID(arr(i)) m.To = " AddNewItemToFolder (m) m.Send Next End Sub Public Sub AddNewItemToFolder(oItem As MailItem) Dim oFolder As MAPIFolder Set oFolder = GetNamespace("MAPI").Folders.Item("Forwarded") oFolder.Items.Add (oItem) End Sub But Even though I have a breakpoint in AddNewItemToFolder, I never get there. It's as if the call to this subroutine were commented out. |
How to Add a MailItem to a Folder
That worked! Thanks.
"Dmitry Streblechenko" wrote: Firstly, do not try to send a message that has already been received. Create a new message (Application.CreateItem or MAPIFolder.Items.Add), populate its properties, then send, Secondly. Items.Add create a brand new item and takes either an OlItemType enum (e.g. olMailItem) or a string indicating teh desired message class (e.g. "IPM.Note"). If you want to move an existing item to a folder, use MailItem.Move(). Dmitry Streblechenko (MVP) http://www.dimastr.com/ OutlookSpy - Outlook, CDO and MAPI Developer Tool "RON" wrote in message ... I have created a folder called "Forwarded" and I am using this code: Private Sub outApp_NewMailEx(ByVal EntryIDCollection As String) ' Dim oFolder As MAPIFolder ' Set oFolder = GetNamespace("MAPI").GetDefaultFolder(olFolderInbo x) Dim arr() As String Dim i As Integer Dim m As MailItem On Error Resume Next arr = Split(EntryIDCollection, ",") For i = 0 To UBound(arr) Set m = Application.Session.GetItemFromID(arr(i)) m.To = " AddNewItemToFolder (m) m.Send Next End Sub Public Sub AddNewItemToFolder(oItem As MailItem) Dim oFolder As MAPIFolder Set oFolder = GetNamespace("MAPI").Folders.Item("Forwarded") oFolder.Items.Add (oItem) End Sub But Even though I have a breakpoint in AddNewItemToFolder, I never get there. It's as if the call to this subroutine were commented out. |
All times are GMT +1. The time now is 09:12 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-2006 OutlookBanter.com