This integration allows us to insert either a recipient or a list of recipients from Outlook. The setup for the options differs, for which reason this article will elaborate on both ways of configuring the integration.
Furthermore, we can (with DocumentData) both read the fields when writing an email as well as write in them. This is also explained later in the article.
Insert a recipient from Outlook
We are able to insert a recipient from the Outlook address book into a document in Word. Using content controls, we define which data that should be imported and where to place it.
The module is located here:
...\ModuleLibrary\DocumentData\02_nocontext_Insert Recipient\01_insertOutlookRecipient.xml
CMD
<Cmd case="SkabelonDesign.OutlookAddressBook:insert-recipient" prefix="x" clearOnCancel="x"/>
Parameters
prefix
Define name of prefix, e.g. "Outlook".
clearOnCancel
Define whether the data should be cleared when clicking cancel in the dialog box. If this parameter is set to be true
, it clears the previous data. If false
, it just keeps the existing data if cancelled.
Binding
As mentioned, we use content controls to receive the data, thus there must be a tag in the certain content control, where the grabbed data should be inserted. This is the binding that should be inserted in the tag:
{"SkabelonDesign":{"type":"Text","binding":"prefix.Value"}}
The prefix in the binding must be replaced with whatever is defined in our prefix parameter in the command. For instance, if you have written Outlook
in the command above, this is your prefix.
There are several values from Outlook:
- FullName
- FirstName
- LastName
- DisplayName
- StreetAddress
- PostalCode
- City
- BusinessPhone
- MobilePhone
- JobTitle
- Company
- Department
As an example, imagine having a document where you want to insert a recipient's full name and email. Create two content controls and insert the binding above in their tags. In the first one, wherein the name should be inserted, the tag should look like this:
{"SkabelonDesign":{"type":"Text","binding":"Outlook.FullName"}}
The tag in the secound content control should look like this:
{"SkabelonDesign":{"type":"Text","binding":"Outlook.Email"}}
Insert recipient list from Outlook
We are also able to insert a list of recipients from Outlook. In this way, we support inserting multiple "to", "cc" and "bcc". Here, we target a parent content control that contains the content controls above.
The module is located here:
...\ModuleLibrary\DocumentData\02_nocontext_Insert Recipient\02_insertRecipientList.xml
CMD
<Cmd case="SkabelonDesign.OutlookAddressBook:insert-recipient-list" prefix="x" clearOnCancel="x"/>
The parameters in this command works in the same way as in the first command.
Binding
The binding for the parent content control is very similar to the binding above. Though, the type must be either ListRepeat
or ListRepeatInLine
. With ListRepeat
, there will automatically be a break after every inserted recipient in the list, while ListRepeatInLine
will create a string of the inserted recipients. When using ListRepeatInLine
, it is handy to insert a separator after the content controls for the first recipient in the parent content control. The separator is a content control named Separator
in both title and tag, and as an example, it can contain a comma. This ensures that it will be repeated for every item in the parent content control and hidden for the last one. Here is an example:
In the binding for inserting a list of recipients, the value can be either To
, Cc
or Bcc
depending on what kind of recipient it is.
As an example, we need to insert multiple recipients with full name and email, thus we can use the content controls above as child content controls. These must be placed in a parent content control. In this example, I use this binding in the tag of the parent content control:
{"SkabelonDesign":{"type":"ListRepeat","binding":"Outlook.To"}}
This content control can then contain the content controls with the binding for the values that you will need from the recipient from Outlook. Since the two content controls from before now are child content controls in this case, we need to insert item:
in their binding, so it looks like this:
item:{"SkabelonDesign":{"type":"Text","binding":"Outlook.FullName"}}
Read from and write in Outlook mail fields
We can with DocumentData in Outlook both read the fields when writing a mail, and also write in them.
In the example below, we both read the subject field of a mail draft, and change it.
<cmd case="SkabelonDesign.DocumentData:DefineData" variableName="Mail.Subject">
<Mail.Subject>
<s>The subject is</s><Mail.Subject/><s>, test test</s>
</Mail.Subject>
</cmd>
You can insert the following values in variableName
or elsewhere in DocumentData for reading and writing in mail fields.
Mail.To
This is for reading and writing in the recipient field of a mail.
Mail.Cc
This is for reading and writing in the Cc field of a mail.
Mail.Bcc
This is for reading and writing in the Cc field of a mail.
Mail.Subject
This is for reading and writing in the Cc field of a mail.
Mail.From
Note that you can only read from this field, as it is not a traditional editable field like the fields in a mail.
It should also be noted, that Outlook can sometimes automatically change the name of the senders email. For example in this client's solution, they want a specific mail in Bcc based on what mail is in Mail.From. When inserting the mail in their environment however, the mail changes into the name of the mail. Therefore, the solution has been configured as in the example below to circumvent this issue.
<cmd case="BaseExtensions:If" if-1-type="DOCUMENTDATA" if-1-key-1="Mail.From" if-1-value-1="Postkasse Bilskade">
<True>
<cmd case="SkabelonDesign.DocumentData:DefineData" variableName="Mail.Bcc">
<s>ocrbil@lb.dk</s>
</cmd>
</True>
</cmd>
Comments
0 comments
Article is closed for comments.