![]() |
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 |
#9
|
|||
|
|||
![]()
OK Ken,
It seems so close and yet so far away. I am doing the message class but anytime it htis a delivery report or read receipt, I cannot get the message class. I have a check to add the category "Not Copied" (it exists in the list) and it will change the category of the message prior to the receipt. The message box never displays a "REPORT" message class just "IPM.NOTE" and the out of office one. I am including the code and am hoping a light will shine on the error in the code. Thanks for your continued assistance. Chris -----CODE START----- Dim TheEmail As Outlook.MailItem Dim eItem As Outlook.Items Dim EmailNS As NameSpace Dim fldrCount, EmailPath2, NbrItem, myfolder Dim strSubj, strTime, mailClassCheck, EmailPath As String Dim NewFileName As String Dim Cats Dim CheckErr, Exists As Boolean CheckErr = False Set EmailNS = Application.GetNamespace("MAPI") Set myfolder = Application.ActiveExplorer.CurrentFolder NbrItem = myfolder.Items.Count On Error GoTo Error_Handler 'EmailPath = InputBox("Enter the save folder location:", "Email Save Path", CurDir) EmailPath = "C:\users\CMPurdom\Desktop\Mail Burn\Tester\" For i = 1 To NbrItem Set TheEmail = Application.ActiveExplorer.CurrentFolder.Items.Ite m(i) mailClassCheck = TheEmail.MessageClass MsgBox mailClassCheck If Right(mailClassCheck, 6) = "REPORT" Then SaveMailAsFile TheEmail, olSaveAsMsg, "C:\users\CMPurdom\Desktop\Mail Burn\Testers\" GoTo Step1 End If If TheEmail.Subject = "" Then strSubj = "no subject" strSubj = Replace(TheEmail.Subject, "/", "-") strSubj = Replace(strSubj, "\", "-") strSubj = Replace(strSubj, ":", "--") strSubj = Replace(strSubj, "?", sReplace) strSubj = Replace(strSubj, Chr(34), sReplace) strSubj = Replace(strSubj, "", sReplace) strSubj = Replace(strSubj, "", sReplace) strSubj = Replace(strSubj, "|", sReplace) strTime = Replace(TheEmail.ReceivedTime, "/", "-") strTime = Replace(strTime, "\", "-") strTime = Replace(strTime, ":", ".") strTime = Replace(strTime, "?", sReplace) strTime = Replace(strTime, Chr(34), sReplace) strTime = Replace(strTime, "", sReplace) strTime = Replace(strTime, "", sReplace) strTime = Replace(strTime, "|", sReplace) 'SaveMailAsFile TheEmail, olSaveAsMsg, "C:\users\CMPurdom\Desktop\Mail Burn\Testers\" NewFileName = TheEmail.SenderName & "_" & strTime & "_" & strSubj & ".msg" If NewFileName "" Then TheEmail.SaveAs EmailPath & NewFileName, olMSG Else MsgBox "No file name was entered. Operation aborted.", 64, "Cancel Operation" Exit Sub End If Step1: Next i GoTo Done Error_Handler: MsgBox TheEmail.MessageClass & Chr$(13) & TheEmail.Subject & Chr$(13) & Err.Number & ": " & Err.Description TheEmail.Categories = TheEmail.Categories & ";" & "Not Copied" TheEmail.Save Resume Next Done: End Sub -----CODE END----- "Ken Slovak - [MVP - Outlook]" wrote: You need to check the item's MessageClass property, which is a string. If you are doing that in a procedure or event handler where the item is an Object you would do that using reflection. If you use Class, which won't work for you correctly, you will need to try a cast to MailItem, if that fails try a cast to ReportItem and so on. Personally I'd be using MessageClass myself. I'd get MessageClass and use string.StartsWith() to see if the MessageClass starts with "REPORT". -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "Chris" wrote in message ... Ken, The Class I was referring to is the Application.ActiveExplorer.CurrentFolder.Items.Ite m(I).Class. I had a return of 43. I do not know how to utilize MessageClass to isolate as it seems to call the delivery receipt IPM.NOTE according to what was outputted to the messagebox and not as what you had below. I am using Outlook 2007. Chris . |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
MailItem SaveAs | Koen Verwimp | Add-ins for Outlook | 2 | September 22nd 08 01:41 PM |
MailItem.SaveAs encoding characters wrong from HTML message | MattS | Outlook and VBA | 3 | April 1st 08 02:26 PM |
MailItem.SaveAs method | Mrunali | Outlook - Using Forms | 0 | April 17th 07 03:16 PM |
_MailItem - SaveAs | MON205 | Add-ins for Outlook | 1 | February 22nd 07 06:01 PM |
How can I create a MailItem that displays like a received MailItem ? | Clive | Outlook - Using Forms | 0 | February 27th 06 04:14 PM |