Ferocious Outlook VBA script:outlook VBA Script that gets info on currently selected email using various property

Source: Internet
Author: User
Tags propertyaccessor mail account

Option Explicit ' VBA Script that gets info on the currently selected email using propertyaccessor and various syntaxes ' (s EE other scripts at http://www. Gregthatcher.com-Ways to get mail properties) ' property Tag Syntax looks like this http://schemas.microsoft.com /mapi/proptag/0x0005000b ' property Tag Syntax are used for Outlook ' Properties ' (defined by Outlook Object Model) ' Propert Y ID Syntax looks like this http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-c000-000000000046}/8586001f ' Property ID Syntax are used for MAPI Named properties (optional Outlook properties that can ' t be deleted) and Userpropertie S (properties you can add which is visible to the user) "Named property Syntax looks like this http://schemas.microsoft. Com/mapi/string folloowed by a property name ' Named property Syntax are used to create and view ' Named Properties ' (propert IES can create, but which is not visible to the user) "Office document syntax looks like This:urn:schemas-microsoft -Com:office:outlook#source-table-label ' use Tools->macro->security to allow Macros to run and then restart Outlook ' Ru n Outlook, press ALT+F11 to open VBA ' programming by Greg Thatcher, http://www. Gregthatcher.com ' This SCRIPT would only be RUN on Outlook later (it won ' t work on Outlook 2003 – there is no Propert Yaccessor) "To find the DASL definition of Outlook Properties, with the method described in Professional Outlook Prog Ramming (Programmer to Programmer) by Ken Slovak ' from the ' Views ' menu, create a new view (but don ' t save it) ' Click on t  He ' advanced ' tab, and choose ' Filter ' Choose a field from the ' field ' dropdown, also choose a condition and value ' Click On the ' Sql tab ' Check the ' Edit these Criteria ' checkbox ' public Sub getcurrentmailinfousingpropertyaccessor () Dim Se    Ssion as Outlook.NameSpace Dim currentexplorer As Explorer Dim Selection As Selection Dim currentitem As Object Dim currentmail As MailItem Dim report As String Dim propertYaccessor as Outlook.propertyaccessor Dim Stringarray () As String Dim index Dim currentstring Dim TempVal Set currentexplorer = Application.ActiveExplorer Set Selection = Currentexplorer.selection ' for any items do.    ..                        For each currentitem in Selection If currentitem.class = Olmail then Set currentmail = CurrentItem Set PropertyAccessor = currentmail.propertyaccessor report = report & Amp Addtoreportifnotblank ("Auto forwarded", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/proptag/ 0x0005000b ")) & VbCrLf report = report & Addtoreportifnotblank (" BCC ", PropertyAccessor.GetProperty (" urn : Schemas:calendar:resources ")) & VbCrLf report = report & Addtoreportifnotblank (" Billing Information ", PropertyAccessor.GetProperty ("Urn:schemas:contacts:billinginformation")) & VbCrLf Stringarray () = Propertya Ccessor. GetProperty ("UrN:schemas-microsoft-com:office:office#keywords ") for index = LBound (Stringarray) to UBound (Stringarray) Report = report & "Categories (" & Index & ")" & Stringarray (Index) & vbCrLf Next Index report = report & Addtoreportifnotblank ("Cc", PropertyAccessor.GetProperty ("Urn:schemas:httpmail:disp LAYCC ")) & VbCrLf report = report & Addtoreportifnotblank (" Changed by ", PropertyAccessor.GetProperty (" H ttp://schemas.microsoft.com/mapi/proptag/0x3ffa001f ")) & VbCrLf report = report & Addtoreportifnotblank ("Contacts", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000- c000-000000000046}/8586001f ")) & VbCrLf report = report & Addtoreportifnotblank (" Conversation ", Propert Yaccessor.getproperty ("Urn:schemas:httpmail:thread-topic")) & VbCrLf report = report & Addtoreportifnot Blank ("Created", PropertyAccessor.GetProperty ("urn:schemas:calendar:created")) & VbCrLf report = report & Addtoreportifnotblank ("Defer Until", proper Tyaccessor.getproperty ("Http://schemas.microsoft.com/exchange/deferred-delivery-iso")) & vbCrLf report = RE Port & Addtoreportifnotblank ("Do not AutoArchive", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/ mapi/id/{00062008-0000-0000-c000-000000000046}/850e000b ")) & VbCrLf report = report & ADDTOREPORTIFNOTB Lank ("Due Date", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id/{00062003-0000-0000- c000-000000000046}/81050040 ")) & VbCrLf report = report & Addtoreportifnotblank (" E-mail Account ", Prope Rtyaccessor.getproperty ("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-c000-000000000046}/8580001f" ) & VbCrLf report = report & Addtoreportifnotblank ("Expires", PropertyAccessor.GetProperty ("Urn:schema S:mailheader:expiry-date ")) & vbCrLf report = rEport & Addtoreportifnotblank ("Flag complated Date", PropertyAccessor.GetProperty ("http://schemas.microsoft.com /mapi/proptag/0x10910040 ")) & VbCrLf report = report & Addtoreportifnotblank (" Flag Status ", PROPERTYACC Essor. GetProperty ("http://schemas.microsoft.com/mapi/proptag/0x10900003")) & VbCrLf report = report & Addtore            Portifnotblank ("Follow Up Flag", PropertyAccessor.GetProperty ("Urn:schemas:httpmail:messageflag")) & VbCrLf Report = report & Addtoreportifnotblank ("From", PropertyAccessor.GetProperty ("Urn:schemas:httpmail:fromname")) & vbCrLf report = report & Addtoreportifnotblank ("has replies Sent to", PropertyAccessor.GetProperty (" http://schemas.microsoft.com/mapi/proptag/0x0050001f ")) & VbCrLf report = report & Addtoreportifnotblan K ("IMAP Status", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-      C000-000000000046}/85700003 ")) & VbCrLf      Report = report & Addtoreportifnotblank ("Importance", PropertyAccessor.GetProperty ("Urn:schemas:httpmail:import Ance ")) & vbCrLf ' report = report & Addtoreportifnotblank (" In Folder ", PropertyAccessor.GetProperty (" HT tp://schemas.microsoft.com/mapi/proptag/0x0e05001f ")) & VbCrLf report = report & Addtoreportifnotblank ( "InfoPath Form Type", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000- c000-000000000046}/85b1001f ")) & vbCrLf ' report = report & Addtoreportifnotblank (" Message ", PROPERTYACC Essor. GetProperty ("Urn:schemas:httpmail:textdescription")) & VbCrLf report = report & Addtoreportifnotblank ("            Message Class ", PropertyAccessor.GetProperty (" http://schemas.microsoft.com/mapi/proptag/0x001a001e ")) & VbCrLf Report = report & Addtoreportifnotblank ("Mileage", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/    Exchange/mileage ")) & VbCrLf        Report = report & Addtoreportifnotblank ("Modified", PropertyAccessor.GetProperty ("Dav:getlastmodified")) & VbCrLf report = report & Addtoreportifnotblank ("Originator Delivery requested", Propertyaccessor.getproper Ty ("http://schemas.microsoft.com/exchange/deliveryreportrequested")) & vbCrLf ' report = report & Addtor Eportifnotblank ("Outlook Data File", PropertyAccessor.GetProperty ("urn:schemas-microsoft-com:office:outlook# Source-table-label ")) & VbCrLf report = report & Addtoreportifnotblank (" Outlook Internal Version ", prop Ertyaccessor.getproperty ("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000-c000-000000000046}/85520003 ) & VbCrLf report = report & Addtoreportifnotblank ("Outlook Version", PropertyAccessor.GetProperty ("H ttp://schemas.microsoft.com/mapi/id/{00062008-0000-0000-c000-000000000046}/8554001f ")) & vbCrLf report = RE Port & Addtoreportifnotblank ("Receipt requesteD ", PropertyAccessor.GetProperty (" http://schemas.microsoft.com/exchange/readreceiptrequested ")) & VbCrLf RE Port = report & Addtoreportifnotblank ("Received", PropertyAccessor.GetProperty ("Urn:schemas:httpmail: Datereceived ")) & VbCrLf report = report & Addtoreportifnotblank (" Received representing Name ", Accessor.getproperty ("http://schemas.microsoft.com/mapi/proptag/0x0044001f")) & vbCrLf ' report = Report &am P Addtoreportifnotblank ("Recipient Name", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/received _by_name ")) & VbCrLf report = report & Addtoreportifnotblank (" Relevance ", PropertyAccessor.GetProperty ( "http://schemas.microsoft.com/mapi/proptag/0x10840003")) & VbCrLf report = report & Addtoreportifnotbla NK ("Reminder", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id/{00062008-0000-0000- c000-000000000046}/8503000b ")) & vbCrLf report = RepoRT & Addtoreportifnotblank ("Remote Status", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id /{00062008-0000-0000-c000-000000000046}/85110003 ")) & vbCrLf ' report = report & Addtoreportifnotblank (" Retrieval Time ", PropertyAccessor.GetProperty (" http://schemas.microsoft.com/mapi/id/{00062014-0000-0000- C000-000000000046}/8f040003 ")) & vbCrLf ' report = report & Addtoreportifnotblank (" RSS feed ", Propertyac Cessor. GetProperty ("http://schemas.microsoft.com/mapi/id/{00062041-0000-0000-c000-000000000046}/8904001f")) & VbCrLf report = report & Addtoreportifnotblank ("Sensitivity", PropertyAccessor.GetProperty ("Http://schemas. Microsoft.com/exchange/sensitivity-long ")) & VbCrLf report = report & Addtoreportifnotblank (" Sent ", pro Pertyaccessor.getproperty ("Urn:schemas:httpmail:date")) & VbCrLf report = report & Addtoreportifnotblan K ("Signed by", PropertyAccessor.GetProperty ("Http://schemas.microsoft.com/mapi/id/{00020328-0000-0000-c000-000000000046}/9104001f ")) & VbCrLf report = report & A Ddtoreportifnotblank ("Start Date", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id/{ 00062003-0000-0000-c000-000000000046}/81040040 ")) & VbCrLf report = report & Addtoreportifnotblank (" Sub Ject ", PropertyAccessor.GetProperty (" Urn:schemas:httpmail:subject ")) & VbCrLf report = report & Addtore Portifnotblank ("Task Subject", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id/{ 00062008-0000-0000-c000-000000000046}/85a4001f ")) & VbCrLf report = report & Addtoreportifnotblank (" to " , PropertyAccessor.GetProperty ("Urn:schemas:httpmail:displayto")) & VbCrLf report = report & Addtorepor Tifnotblank ("Tracking Status", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id/{ 0006200b-0000-0000-c000-000000000046}/88090003 ")) & vbCrLf report = Report & Addtoreportifnotblank ("Voting Response", PropertyAccessor.GetProperty ("http://schemas.microsoft.com/mapi/id /{00062008-0000-0000-c000-000000000046}/8524001f ")) & vbCrLf End If Next Call CreateReport Asemail ("Email properties from PropertyAccessor using various property syntaxes", report) End SubPrivate Function Addtorep Ortifnotblank (FieldName as String, fieldvalue) Addtoreportifnotblank = "" If (IsNull (fieldvalue) Or fieldvalue <& Gt  "") Then Addtoreportifnotblank = FieldName & ":" & Fieldvalue & VbCrLf end If End Function ' VBA Subroutine which displays a report inside an e-mail ' programming by Greg Thatcher, http://www.  Gregthatcher.compublic Sub Createreportasemail (Title As String, Report as String) on Error GoTo on_error Dim Session As Outlook.NameSpace Dim mail As MailItem Dim MyAddress As AddressEntry Dim Inbox Set Session = application.s Ession Set Inbox = Session.GetDefaultFolder (Olfolderinbox) Set mail = Inbox.Items.Add ("IPM. Mail ") Mail. Subject = Title Mail. Body = Report Mail. Save Mail. Display Exiting:set Session = Nothing Exit subon_error:msgbox "error=" & Err.Number & "" &A mp Err.Description Resume exitingend Sub

Applies to: More than Outlook 2007.

Transferred from: http://www.gregthatcher.com/Scripts/VBA/Outlook/GetEmailInfoUsingPropertyAccessor.aspx

Ferocious Outlook VBA script:outlook VBA Script that gets info on currently selected email using various property

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.