View Single Post
  #2  
Old January 10th 07, 09:35 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default 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.



Ads