Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Mickers Outlook COM MSDN for Ahk_L


  • Please log in to reply
35 replies to this topic
Mickers
  • Members
  • 1239 posts
  • Last active: Sep 25 2015 03:03 PM
  • Joined: 11 Oct 2010
This thread is an ongoing project to document all of Microsoft Office Outlook's properties and methods as a reference for future Ahk scripters.
I wanted to learn more about COM in general and more specifically for Outlook. I figure the best way would be to read through the entire MSDN and code some examples so that I feel I truly understand how it works.

Any comments, examples, or flaws in this page please post below. Any examples given I will make sure to give credit to the author. :)

Below this will eventually be the index with reference numbers:
=========================================

Outlook Application Object Members References:
Application Object Members (Outlook) Office 2003
Application Object Members (Outlook) Office 2007
Application Object Members (Outlook) Office 2010
~Added by jethrow

Mickers
  • Members
  • 1239 posts
  • Last active: Sep 25 2015 03:03 PM
  • Joined: 11 Oct 2010
========================================================
=== Application Object ===
========================================================
~Represents the entire Outlook application.
Application := ComObjActive("Outlook.Application")
~You can use CreateItem directly from this object without traversing the entire hierarchy.

--------------------------------------------------------
=== Application Methods ===
--------------------------------------------------------
ActiveExplorer
~Returns the topmost Explorer object on the desktop.
~Returns nothing if no explorer is active.
ActiveExplorer := ComObjActive("Outlook.Application").ActiveExplorer
ActiveInspector
~Returns the topmost Inspector object on the desktop.
~Returns nothing if no inspector is active.
ActiveInspector := ComObjActive("Outlook.Application").ActiveInspector
ActiveWindow
~Returns the topmost Microsoft Outlook window which can be either an Explorer or Inspector object.
~Returns nothing if no explorer or inspector is open.
ActiveWindow := ComObjActive("Outlook.Application").ActiveWindow
AdvancedSearch
~Returns a Search Object.
~Use the Save Method to retain the search filter.

Application.AdvancedSearch(Scope, Filter, SearchSubFolders, Tag)
- Scope (Required): The folder path.
- Filter (Optional): The DASL filter that defines the parameters or the search.
- SearchSubFolders (Optional): also search sub folders.
- Tag: The name of the search for saving purposes.

CopyFile
Application.CopyFile(FilePath, DestFolderPath)
- FilePath (Required): The path of the file to copy.
- DestFolderPath (Required): Path of the location to copy to.
Path := "C:\Documents and Settings\" . A_UserName . "\Desktop\Book1.xls" ;create a blank workbook on your desktop
File := ComObjActive("Outlook.Application").CopyFile(Path, "Inbox")
CreateItem
Application.CreateItem(ItemType)
- ItemType (Required): The OlItemTypetype for the new item.
~This method can only create default items.
;example of creating a MailItem and setting it's format to HTML
olMailItem := 0
MailItem := ComObjActive("Outlook.Application").CreateItem(olMailItem)
olFormatHTML := 2
MailItem.BodyFormat := olFormatHTML
MailItem.HTMLBody := "<HTML><H2>The body of this message will appear in HTML.</H2><BODY> Please enter the message text here. </BODY></HTML>"
MailItem.Display
CreateItemFromTemplate
Application.CreateItem(TemplatePath, InFolder)
- TemplatePath (Required): The path and file name of the template.
- InFolder (Optional): The folder where the item will go. If empty will go to the default folder.
;create a template
olMailItem := 0
Item := ComObjActive("Outlook.Application").CreateItem(olMailItem)
Item.Subject := "Testing"
Item.To := "Myself"
Item.Display
Item.SaveAs("C:\Testing.oft") ;outlook may detect this action as a virus
;create new message with template
Item := Application.CreateItemFromTemplate("C:\Documents and Settings\" .  A_UserName . "\ApplicationData\Microsoft\Templates\Testing.oft")
Item.Display
CreateObject
~Creates an Automation object of the specified class.
Application.CreateObject(ObjectName)
- ObjectName (Required): The name of the object class to create.
IE := ComObjActive("Outlook.Application").CreateObject("InternetExplorer.Application")
IE.Visible := 1 ;true
IE.Navigate("www.microsoft.com")
GetNamespace
~Returns the NameSpace object of a certain type.
Application.GetNamespace(Type)
- Type (Required): "MAPI" is the only type supported.
NameSpace:= ComObjActive("Outlook.Application").GetNameSpace("MAPI")
GetObjectReference
~Creates a strong or weak object reference for a specified Outlook object.
Application.GetObjectReference(Item, ReferenceType)
- Item (Required): The object to reference.
- ReferenceType(Required): The object's type.
- olStrong := 1
- olWeak := 0
;Item := ?
Reference := ComObjActive("Outlook.Application").GetObjectReference(Item, 0)
IsSearchSynchronous
~Returns true or false indicating if a search will be synchronous or asynchronous.
~True if synchronous and false otherwise.
Application.IsSearchSynchronous(LookInFolders)
- LookInFolders (Required): The path to the folders to search. Enclose the path with single quotes.
Application := ComObjActive("Outlook.Application").IsSearchSynchronous("My Documents")
Quit
~Logs you completely out of Outlook.
Application := ComObjActive("Outlook.Application").Quit
;or
Application.Quit
--------------------------------------------------------
=== Application Properties ===
--------------------------------------------------------
Application
~Returns an Application object that represents the parent Outlook application.
Application := ComObjActive("Outlook.Application")
;or
Application := ComObjCreate("Outlook.Application")
Assistance
~Returns an Assistance object used to invoke help.
Application := ComObjActive("Outlook.Application")
Assistance := Application.Assistance
Class
~Returns an constant indicating the object's class.
Application := ComObjActive("Outlook.Application")
Class := Application.Class
COMAddIns
~Returns a COMAddIns collection that represents all the Component Object Model (COM) add-ins currently loaded in Microsoft Outlook.
MsgBox % "There are " . ComObjActive("Outlook.Application").COMAddIns.Count . " COM add ins."
DefaultProfileName
~Returns the default profile name.
MsgBox % "The default profile name is """ . ComObjActive("Outlook.Application").DefaultProfileName . """."
Explorers
~Returns a Explorers collection of all open Explorer objects.
MsgBox % "There are " . ComObjActive("Outlook.Application").Explorers.Count . " explorers in the collection."
Inspectors
~Returns a Inspectors collection of all open InspectorObjects.
Application := ComObjActive("Outlook.Application")
If (Application.Inspectors.Count = 0)
MsgBox, No Inspectors open.
Else {
Loop % Application.Inspectors.Count
Message .= Application.Inspectors.Item(A_Index).Caption . "`n"
MsgBox % Message
}
IsTrusted
~Returns True or False to indicate if an add-in or external caller is considered trusted.
If (ComObjActive("Outlook.Application").IsTrusted = 1)
MsgBox, The add-in or external caller is trusted
Else MsgBox, The add-in or external caller is not trusted
LanguageSettings
~Returns a LanguageSettingsobject for the application that contains the language-specific attributes of Outlook.
LanguageSettings := ComObjActive("Outlook.Application").LanguageSettings
Name
~Returns the display name for the object.
MsgBox % "The display name is " . ComObjActive("Outlook.Application").Name . "."
Parent
~Returns the parent Object of the specified object.
Parent := ComObjActive("Outlook.Application").Parent
ProductCode
~Returns a String specifying the Microsoft Outlook globally unique identifier (GUID).
ProductCode := ComObjActive("Outlook.Application").ProductCode
Reminders
~Returns a Reminders collection that represents all current reminders.
;example 1
For Reminder in ComObjActive("Outlook.Application").Reminders
MsgBox % Reminder.Caption
;example 2
MsgBox % ComObjActive("Outlook.Application").Reminders.Count
Session
~Returns the NameSpaceobject for the current session.
~The GetNamespacemethod can be used to accomplish the same thing. Only MAPI is supported.
Session := ComObjActive("Outlook.Application").Session
;or
Session := ComObjActive("Outlook.Application").GetNamespace("MAPI")
TimeZones
~Returns a TimeZonescollection that represents the set of time zones supported by Outlook.
TimeZones := ComObjActive("Outlook.Application").TimeZones
Loop % TimeZones.Count {
TimeZone := TimeZones.Item(A_Index)
Message .= TimeZone.Name . "`n"
} MsgBox % Message
Version
~Returns or sets a String indicating the number of the version.
MsgBox % ComObjActive("Outlook.Application").Version


Mickers
  • Members
  • 1239 posts
  • Last active: Sep 25 2015 03:03 PM
  • Joined: 11 Oct 2010
========================================================
=== Stores ===
========================================================
Stores Object
~A set of Store objects representing all the stores available in the current profile.
Stores := ComObjActive("Outlook.Application").Session.Stores
--------------------------------------------------------
=== Stores Methods ===
--------------------------------------------------------
Item
~Returns a Store object that is specified by Index.
Stores.Item(Index)
Stores := ComObjActive("Outlook.Application").Session.Stores
MsgBox % Store := Stores.Item(1).DisplayName
--------------------------------------------------------
=== Stores Properties===
--------------------------------------------------------
Application
~Returns an Application object that represents the parent Outlook application for the object.
Application := ComObjActive("Outlook.Application").Session.Application
Class
~Returns an OlObjectClass constant indicating the object's class.
MsgBox % ComObjActive("Outlook.Application").Session.Stores.Class
Count
~Returns a Long indicating the count of objects in the specified collection.
MsgBox % ComObjActive("Outlook.Application").Session.Stores.Count
Parent
~Returns the parent Object of the specified object which is the NameSpace object.
Parent := ComObjActive("Outlook.Application").Session.Stores.Parent
Session
~Returns the NameSpace object for the current session.
Session := ComObjActive("Outlook.Application").Session
;or
NameSpace := ComObjActive("Outlook.Application").GetNamespace("MAPI") ;MAPI is the only accepted constant
--------------------------------------------------------
=== Stores Events ===
--------------------------------------------------------
BeforeStoreRemove
~Occurs when a Store is about to be removed from the current session either programmatically or through user action.
Stores.BeforeStoreRemove(Store, Cancel)
- Store(Required): The Store object to be removed from the current session.
- Cancel(Required): True to cancel the removal of the specified store, False otherwise.
~Stores can be removed by calling Session.RemoveStore
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1).DisplayName
Stores.BeforeStoreRemove(Store, False)
StoreAdd
~Occurs when a Store has been added to the current session either programmatically or through user action.
Stores.StoreAdd(Store)
- Store(Required): The Store to be added to the current session.
~A Store can be added by using the Session.AddStore method.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1).DisplayName
Stores.StoreAdd(Store)


Mickers
  • Members
  • 1239 posts
  • Last active: Sep 25 2015 03:03 PM
  • Joined: 11 Oct 2010
========================================================
=== Store Object ===
========================================================
~Represents a file on the local computer or a network drive that stores e-mail messages and other items for an account in the current profile.

--------------------------------------------------------
=== Store Methods ===
--------------------------------------------------------
GetRootFolder
~Returns a Folder object representing the root-level folder of the Store.
~The Parent propery returns "MAPI".
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Root := Store.GetRootFolder
Folders := Root.Folders
Loop % Folders.Count
	Message .= Folders.Item(A_Index).Name . "`n"
MsgBox % Message
GetRules
~Returns a Rules collection object that contains the Rule objects defined for the current session.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Loop % Rules.Count
	Message .= Rules.Item(A_Index).Name . "`n"
MsgBox % Message
GetSearchFolders
~Returns a Folders collection object that represents the search folders defined for the Store object.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Folders := Store.GetSearchFolders
Loop % Folders.Count
	Message .= Folders.Item(A_Index).Name . "`n"
MsgBox % Message
GetSpecialFolder
~Returns a Folder object for a special folder specified by FolderType in a given store.
Store.GetSpecialFolder(FolderType)
- FolderType(Required): A constant in the OlSpecialFolders enumeration that specifies the type of the special folder in the store.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Folder0 := Store.GetSpecialFolder(0)
Folder1 := Store.GetSpecialFolder(1)
If (Folder0 = "") or (Folder1 = "")
	MsgBox, Nata
Else MsgBox % Folder0.Name . ", " . Folder1.Name
--------------------------------------------------------
=== Store Properties ===
--------------------------------------------------------
Application
~Returns an Application object that represents the parent Outlook application for the object.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1).Application
Class
~Returns an OlObjectClass constant indicating the object's class.
Stores := ComObjActive("Outlook.Application").Session.Stores
Loop % Stores.Count
	Message .= Stores.Item(A_Index).Class . "`n"
MsgBox % Message
DisplayName
~Returns a String representing the display name of the Store object.
Stores := ComObjActive("Outlook.Application").Session.Stores
Loop % Stores.Count
	Message .= Stores.Item(A_Index).DisplayName . "`n"
MsgBox % Message
ExchangeStoreType
~Returns a constant in the OlExchangeStoreType enumeration that indicates the type of an Exchange store.
Stores := ComObjActive("Outlook.Application").Session.Stores
Loop % Stores.Count
	Message .= Stores.Item(A_Index).ExchangeStoreType . "`n"
MsgBox % Message
FilePath
~Returns a String representing the full file path for a Personal Folders File (.pst) or an Offline Folder File (.ost) store.
Stores := ComObjActive("Outlook.Application").Session.Stores
Loop % Stores.Count
	Message .= Stores.Item(A_Index).FilePath . "`n"
MsgBox % Message
IsCachedExchange
~Returns true or false which indicates if the Store is a cached Exchange store.
~Returns true if it is a olExchangePrimaryMailbox otherwise it returns false.
Stores := ComObjActive("Outlook.Application").Session.Stores
Loop % Stores.Count
	Message .= Stores.Item(A_Index).IsCachedExchange . "`n"
MsgBox % Message
IsDataFileStore
~Returns true or false which indicates if the Store is a store for an Outlook data file, which is either a Personal Folders File (.pst) or an Offline Folder File (.ost).
~IsDataFileStore supports only Exchange stores, and will return False for HTTP-type stores such as Hotmail and MSN, and for IMAP stores.
Stores := ComObjActive("Outlook.Application").Session.Stores
Loop % Stores.Count
	Message .= Stores.Item(A_Index).IsDataFileStore . "`n"
MsgBox % Message
IsInstantSearchEnabled
~Returns true or false which indicates whether Instant Search is enabled and operational on a store.
Stores := ComObjActive("Outlook.Application").Session.Stores
Loop % Stores.Count
	Message .= Stores.Item(A_Index).IsInstantSearchEnabled . "`n"
MsgBox % Message
IsOpen
~Returns true or false which indicates if the Store is open.
Stores := ComObjActive("Outlook.Application").Session.Stores
Loop % Stores.Count
	Message .= Stores.Item(A_Index).IsOpen . "`n"
MsgBox % Message
Parent
~Returns the parent object of the specified object.
Stores := ComObjActive("Outlook.Application").Session.Stores
Parent := Stores.Item(1).Parent
PropertyAccessor
~Returns a PropertyAccessor object that supports creating, getting, setting, and deleting properties of the parent Store object.
Stores := ComObjActive("Outlook.Application").Session.Stores
PropertyAccessor := Stores.Item(1).PropertyAccessor
Session
~Returns the NameSpace object for the current session.
Stores := ComObjActive("Outlook.Application").Session.Stores
Session := Stores.Item(1).Session
StoreID
~Returns a String identifying the Store.
Stores := ComObjActive("Outlook.Application").Session.Stores
Loop % Stores.Count
	Message .= Stores.Item(A_Index).StoreID . "`n"
MsgBox % Message


Mickers
  • Members
  • 1239 posts
  • Last active: Sep 25 2015 03:03 PM
  • Joined: 11 Oct 2010
========================================================
=== Rules Object ===
========================================================
~Represents a set of Rule objects that are the rules available in the current session.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1) ;see stores
Rules := Store.GetRules
--------------------------------------------------------
=== Rules Methods ===
--------------------------------------------------------
Create
~Creates a Rule object with the name specified by Name and the type of rule specified by RuleType.
Rules.Create(Name, RuleType)
- Name(Required): A string identifier for the rule, which will be represented by Rule.Name after rule creation. Names of rules in a collection are not unique.
- RuleType(Required): A constant in the OlRuleType enumeration that determines whether the rule is applied on sending or receiving a message.
Stores := ComObjActive("Outlook.Application").Session.Stores ;see stores
Store := Stores.Item(1) ;see store
Rules := Store.GetRules
olRuleReceive := 0
olRuleSend := 1
Name := "TestRule"
Rules.Create(Name, olRuleReceive)
Item
~Obtains a Rule object specified by Index, which is either a numerical index into the Rules collection or the rule name.
Rules.Item(Index)
- Index(Required): Either a 1-based long value representing an index into the Rules collection, or a string name representing the value of the default property of a rule, Rule.Name.
Stores := ComObjActive("Outlook.Application").Session.Stores ;see stores
Store := Stores.Item(1) ;see store
Rules := Store.GetRules
Loop % Rules.Count
	Message .= Rules.Item(A_Index).Name . "`n"
MsgBox % Message
;or
Loop % Rules.Count
	If (Rules.Item(A_Index).Name = "TestRule")
		MsgBox, Found
Remove
~Removes from the Rules collection a Rule object specified by Index, which is either a numerical index into the Rules collection or the rule name.
Rules.Remove(Index)
- Index(Required): Either a long value representing an index into the Rules collection, or a string name representing the value of the default property of a rule, Rule.Name.
Stores := ComObjActive("Outlook.Application").Session.Stores ;see stores
Store := Stores.Item(1) ;see store
Rules := Store.GetRules
Loop % Rules.Count
	If (Name := Rules.Item(A_Index).Name = "TestRule") {
		Rules.Remove(Name)
		MsgBox, Found
		Break
	}
Save
~Saves all rules in the Rules collection.
Rules.Save(ShowProgress)
- ShowProgress(Optional): True to display the progress dialog box, False to save rules without showing the progress.
Stores := ComObjActive("Outlook.Application").Session.Stores ;see stores
Store := Stores.Item(1) ;see store
Rules := Store.GetRules
Rules.Save(False)
;example using all 4 methods
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules

olRuleReceive := 0
Name := "TestRule"
Rules.Create(Name, olRuleReceive)
Rules.Save(False)

Loop % Rules.Count
	If (Name := Rules.Item(A_Index).Name = "TestRule") {
		Rules.Remove(Name)
		Rules.Save(False)
		MsgBox, Found
		Break
	}
--------------------------------------------------------
=== Rules Properties ===
--------------------------------------------------------
Application
~Returns an Application object that represents the parent Outlook application for the object.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1) ;see stores
Rules := Store.GetRules
Application := Rules.Application
Class
~Returns an OlObjectClass constant indicating the object's class.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1) ;see stores
Rules := Store.GetRules
MsgBox % Class := Rules.Class
Count
~Returns a Long indicating the count of objects in the specified collection.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1) ;see stores
Rules := Store.GetRules
MsgBox % Count := Rules.Count
IsRssRulesProcessingEnabled
~Returns or sets true or false which indicates whether RSS rules processing has been enabled.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1) ;see stores
Rules := Store.GetRules
MsgBox % Boolean := Rules.IsRssRulesProcessingEnabled
Parent
~Returns the parent Object of the specified object.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1) ;see stores
Rules := Store.GetRules
Parent := Rules.Parent
Session
~Returns the NameSpace object for the current session.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1) ;see stores
Rules := Store.GetRules
Session := Rules.Session


Mickers
  • Members
  • 1239 posts
  • Last active: Sep 25 2015 03:03 PM
  • Joined: 11 Oct 2010
========================================================
=== Rule Object ===
========================================================
~Represents an Outlook rule.

--------------------------------------------------------
=== Rule Methods ===
--------------------------------------------------------
Excecute
~Applies a rule as an one-off operation.
Rule.Execute(ShowProgress, Folder, IncludeSubfolders, RuleExecuteOption)
- ShowProgress(Optional): True to display the progress dialog box when the rule is executed, False to run the rule without displaying the dialog box.
- Folder(Optional): Represents the folder where the rule will be applied.
- IncludeSubfolders(Optional): True to apply the rule to subfolders of the folder indicated by the Folder parameter; False to apply the rule only to that folder but not its subfolders.
- RuleExecuteOption(Optional): A OlRuleExecuteOption which represents whether to apply the rule to read, unread, or all messages in the folder or folders specified by the Folder and IncludeSubfolders parameters.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Rule := Rules.Item(1)
ShowProgress := 0 ;default
;Folder := "Inbox" ;default "Error"
;IncludeSubfolders := 0 ;default "Error"
;RuleExecuteOption := 0 ;default "Error"
Rule.Execute(ShowProgress) ;, Folder, IncludeSubfolders, RuleExecuteOption) "Error"
--------------------------------------------------------
=== Rule Properties ===
--------------------------------------------------------
Actions
~Returns a RuleActions collection object that represents all the available rule actions for the rule.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions
MsgBox % RuleActions.Count
Application
~See Application

Class
~Returns an OlObjectClass constant indicating the object's class.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Loop % Rules.Count
	Message .= Rules.Item(A_Index).Class . "`n"
MsgBox % Message
Conditions
Returns a RuleConditions collection object that represents all the available rule conditions for the rule.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleConditions := Rules.Item(1).Conditions
Loop % Rules.Count
	Message .= Class := RuleConditions.Item(A_Index).Class . "`n"
MsgBox % Message
Enabled
~Returns true or false which determines if the rule is to be applied.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
MsgBox % Rules.Item(1).Enabled
Exceptions
~Returns a RuleConditions collection object that represents all the available rule exception conditions for the rule.
~The Exceptions and Conditions properties share the same pool of conditions.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleExceptions := Rules.Item(1).Exceptions
Loop % Rules.Count
	Message .= Class := RuleExceptions.Item(A_Index).Class . "`n"
MsgBox % Message
ExecutionORder
~Returns or sets a Long that indicates the order of execution of the rule among other rules in the Rules collection.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Loop % Rules.Count
	Message .= Rules.Item(A_Index).ExecutionOrder . "`n"
MsgBox % Message
IsLocalRule
~Returns true or false which indicates if the rule executes as a client-side rule.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Loop % Rules.Count
	Message .= Rules.Item(A_Index).IsLocalRule . "`n"
MsgBox % Message
Name
~Returns or sets a String representing the name of the rule.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Loop % Rules.Count
	Message .= Rules.Item(A_Index).Name . "`n"
MsgBox % Message
Parent
~Returns the parent Object of the specified object.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Parent := Rules.Item(1).Parent
RuleType
~Returns a constant from the OlRuleType enumeration that indicates if the rule applies to messages that are being sent or received.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Loop % Rules.Count
	Message .= Rules.Item(A_Index).RuleType . "`n"
MsgBox % Message
;applied to messages that are being received: olRuleReceive(0)
;applied to messages that are being sent: olRuleSend(1)
Session
~See Session.

Mickers
  • Members
  • 1239 posts
  • Last active: Sep 25 2015 03:03 PM
  • Joined: 11 Oct 2010
========================================================
=== RuleActions Object ===
========================================================
~The RuleActions object contains a set of RuleAction objects or objects derived from RuleAction, representing the actions that are executed on a Rule object.

--------------------------------------------------------
=== RuleActions Methods ===
--------------------------------------------------------
Item
~Obtains a RuleAction object specified by Index which is a numerical index into the RuleActions collection.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions
Loop % RuleActions.Count
	Message .= RuleActions.Item(A_Index).ActionType . "`n"
MsgBox % Message
--------------------------------------------------------
=== RuleActions Properties ===
--------------------------------------------------------
Application
~See Application

AssignToCategory
~Returns an AssignToCategoryRuleAction object with AssignToCategoryRuleAction.ActionType being olRuleAssignToCategory.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions
MsgBox % RuleActions.AssignToCategory.Class
CC
~Returns a SendRuleAction object with SendRuleAction.ActionType being olRuleActionCcMessage.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions
MsgBox % RuleActions.CC.Class
Class
~Returns an OlObjectClass constant indicating the object's class.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions
MsgBox % RuleActions.Class
ClearCategories
~Returns a RuleAction object with a RuleAction.ActionType of olRuleActionClearCategories.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions
ClearCategories := RuleActions.ClearCategories
CopyToFolder
~Returns a MoveOrCopyRuleAction object with MoveOrCopyRuleAction.ActionType being olRuleActionCopyToFolder.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions
MsgBox % RuleActions.CopyToFolder.Class
Count
~Returns a Long indicating the count of objects in the specified collection.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions
MsgBox % RuleActions.Count
Delete
~Returns a RuleAction object with RuleAction.ActionType being olRuleActionDelete.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Rules.Item(1).Actions.Delete
DeletePermanently
~Returns a RuleAction object with RuleAction.ActionType being olRuleActionDeletePermanently.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Rules.Item(1).Actions.DeletePermanently
DesktopAlert
~Returns a RuleAction object with RuleAction.ActionType being olRuleActionDesktopAlert.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.DesktopAlert
Forward
~Returns a SendRuleAction object with SendRuleAction.ActionType being olRuleActionForward.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.Forward
ForwardAsAttachment
~Returns a SendRuleAction object with SendRuleAction.ActionType being olRuleActionForwardAsAttachment.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.ForwardAsAttachment
MarkAsTask
~Returns a MarkAsTaskRuleAction object with MarkAsTaskRuleAction.ActionType being olRuleActionMarkAsTask.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.MarkAsTask
MoveToFolder
~Returns a MoveOrCopyRuleAction object with MoveOrCopyRuleAction.ActionType being olRuleActionMoveToFolder.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.MoveToFolder
NewItemAlert
~Returns a NewItemAlertRuleAction object with ActionType being olRuleActionNewItemAlert.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.NewItemAlert
NotifyDelivery
~Returns a RuleAction object with RuleAction.ActionType being olRuleActionNotifyDelivery.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.NewItemAlert
NotifyRead
~Returns a RuleAction object with RuleAction.ActionType being olRuleActionNotifyRead.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.NotifyRead
Parent
~Returns the parent Object of the specified object.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
Parent := Rules.Item(1).Actions.Parent
PlaySound
~Returns a PlaySoundRuleAction object with PlaySoundRuleAction.ActionType being olRuleActionNotifyRead.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.PlaySound
Redirect
~Returns a SendRuleAction object with SendRuleAction.ActionType being olRuleActionRedirect.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.Redirect
Session
~See Session

Stop
~Returns a RuleAction object with RuleAction.ActionType being olRuleActionStop.
Stores := ComObjActive("Outlook.Application").Session.Stores
Store := Stores.Item(1)
Rules := Store.GetRules
RuleActions := Rules.Item(1).Actions.Stop


tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: Oct 13 2016 01:04 AM
  • Joined: 21 Dec 2007
Much more coherent tutorial than your first great job

Suggestion?
explain or give an example of what things like activeExplorer are activeInspector etc. your tuts are touted as noob friendly its easy to forget that as we learn these things such terms become common place to us but is what confused us in the beginning.


Again great documentation model
Never lose.
WIN or LEARN.

Mickers
  • Members
  • 1239 posts
  • Last active: Sep 25 2015 03:03 PM
  • Joined: 11 Oct 2010
@tank
Thanks! Praise from you is rare at best. :D

Suggestion?
explain or give an example of what things like activeExplorer are activeInspector etc. your tuts are touted as noob friendly its easy to forget that as we learn these things such terms become common place to us but is what confused us in the beginning.

Yes your right about that. I'm still learning how Outlook COM works. I've put about 25 hours into this project so far and once I feel it's as complete as I can make it I'll go back and give better examples. :wink:

Zod
  • Members
  • 214 posts
  • Last active: Jan 26 2012 08:02 PM
  • Joined: 06 Jul 2011
I am especially happy because you linked to msdn. lest the reader forget that these are not ahk methods. AHK is just the vehicle
Posted Image Stolen from SKAN

TheGreatSwami Woo
  • Members
  • 237 posts
  • Last active: Jan 22 2012 03:31 PM
  • Joined: 26 May 2011
Example of adding an outlook task?

tank
  • Administrators
  • 4345 posts
  • AutoHotkey Foundation
  • Last active: Oct 13 2016 01:04 AM
  • Joined: 21 Dec 2007
I dont have the time towork the example found here into AHK but perhaps in seeing it it will become obvious to you hwo to do so
Never lose.
WIN or LEARN.

JamixZol
  • Members
  • 54 posts
  • Last active: Jan 22 2014 04:35 AM
  • Joined: 26 Mar 2012
This seems like a good spot for this. I have been fighting an issue with one of my apps for a long time regarding the "Allow external apps" popup and (with the help of a friend) was able to finally get around the issue locally via a registry mod.
I've wrapped the calls in a little GUI to distribute to end users as an optional fix, but the calls are simple enough to work into some logic.
This has been tested with outlook 2007, but is designed to fix the issue with 2010 as well (14.0). This only needs to be run once to set the reg keys.

NOTE: This can bypass exchange server settings for object model guard.
IF YOU DON'T KNOW WHAT THIS IS, OR ARE NOT SURE WHAT THIS MEANS DO NOT RUN IT THIS WILL MODIFY YOUR REGISTRY
^fair warning

Posted Image
; reg key insertion test to allow apps to send through Outlook (god save us all I'm writting registry scripts...)

Gui, Add, Button, x6 y7 w460 h80 gAPPLY_REG_FIX, Apply registry fix to allow apps to send without prompt
Gui, Add, Button, x6 y97 w460 h80 gREMOVE_REG_FIX, Remove registry fix to allow apps to send without prompt
Gui, Add, Text, x6 y187 w460 h120 vOUTPUT_REG_FIX, 
Gui, Show, w477 h316, Outlook registry fixer
return

GuiClose:
ExitApp

APPLY_REG_FIX:
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Office\12.0\Outlook\Security, ObjectModelGuard, 2
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Office\14.0\Outlook\Security, ObjectModelGuard, 2

RegRead, OutputVar12, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Office\12.0\Outlook\Security, ObjectModelGuard
RegRead, OutputVar14, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Office\14.0\Outlook\Security, ObjectModelGuard
GuiControl,,OUTPUT_REG_FIX, Value 2 = never warn`nValue 1 = always warn`nValue 0 = warn if AV is out of date.`n`nOutlook 2007 key entry - %OutputVar12% `nOutlook 2010 key entry - %OutputVar14% `n`nYou must restart Outlook for this change to take effect
return

REMOVE_REG_FIX:
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Office\12.0\Outlook\Security, ObjectModelGuard, 1
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Office\14.0\Outlook\Security, ObjectModelGuard, 1

RegRead, OutputVar12, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Office\12.0\Outlook\Security, ObjectModelGuard
RegRead, OutputVar14, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Office\14.0\Outlook\Security, ObjectModelGuard
GuiControl,,OUTPUT_REG_FIX, Value 2 = never warn`nValue 1 = always warn`nValue 0 = warn if AV is out of date.`n`nOutlook 2007 key entry - %OutputVar12% `nOutlook 2010 key entry - %OutputVar14% `n`nYou must restart Outlook for this change to take effect
return

Manual removal:
Delete the keys
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Outlook\Security
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\14.0\Outlook\Security
restart outlook

References:
More information can be found here on what this is and why it is needed when sending emails through COM with AHK_L
MSDN info here
Discussion on implementation here
Microsoft KB regarding the keys here
Further discussion on implementation here
My code is built and tested for: AutoHotkey_L
Tools:Notify()Builder Dropiler
Libs:RFN Achieve
sಠಠn

Mickers
  • Members
  • 1239 posts
  • Last active: Sep 25 2015 03:03 PM
  • Joined: 11 Oct 2010
Nice. I fell there are too few people that work with Outlook COM which makes me sad as it's one of the more complex of the Microsoft programs (IMO).

Binocular222
  • Members
  • 99 posts
  • Last active: Jul 25 2014 04:28 AM
  • Joined: 26 Feb 2012
No post since 2010?
I think it would be more practical if you give example of how we can do simple things such as show/hide statusbar; create new mail; goto specific mail folder...
Most of your code above only display messages.