Redemption attachement filename escaping differs from Outlook - outlook

We are trying to save attachments selected by the user using Redemption but stumbled on filename escaping inconsistency between VSTO and Redemption. What we do:
By attachment context menu save attachmentSelection[1] index and filename to the db and also message entryId and storeId.
After a while (maybe even after Outlook restart) we need to save this attachment to file. To do this, we get that e-mail with Redemption by id, get attachment by index (rdoMail.Attachments[index]) and also ensure that filename match, since according to this:
https://learn.microsoft.com/en-us/dotnet/api/microsoft.office.interop.outlook.attachment.index?view=outlook-pia#Microsoft_Office_Interop_Outlook_Attachment_Index
index property is valid only during the current session. Although it is not clear what they mean. Can it change if the e-mail is saved and sent already? Or received?
For reply e-mail VSTO Attachment.Filename is "RE Test.msg" and RDOAttachment.Filename is "RE_ Test.msg" (this is msg attachment of another e-mail).
So, the questions are:
why it is different and is it documented somewhere? Can we, for example, replace _ with string.Empty for Redemption filenames or there can be other cases?
Or maybe there is a way to get RDOAttachment from Outlook Attachment object somehow?
Can we rely on that Redemption attachment index is the same as Outlook one?

Sounds like you are dealing with an embedded message attachment - unlike regular by-value attachments that expose the PR_ATTACH_LONG_FILENAME MAPI property, there is no intrinsic file name property for the embedded attachments. Both OOM and Redemption generate that property from the the embedded message subject, whcih you cam access through RDOAttachment.EmbeddedMsg.Subject. OOM does not expose embedded message attachments at all.
Yes, use RDOSession.GetRDOObjectFromOUtlookObject method
The index usually does not change, but it might. MAPI itself uses PR_ATTACH_NUM to open the attachment using IMessage::OpenAttach, but it can be different based on how the message was opened - a fake IMessage returned from MailItem.MAPIOBJECT can have a different value of PR_ATTACH_NUM from the native message returned by the store provider.

Related

How to make ID what is returned by `Office.context.mailbox.item.ItemId` constant, so it is same in Compose and in Sent status of the email?

I'am developing addon for outlook. So for it I am using office.js api. In my addon I want the option to open emails in new window. I store emails ID in db.
Problem is that I "grab" Id of email when it is in compose status, for example, emails ID is AAA. I press sent btn and email now in Sent folder.
As it should, then I want to open that email using my addon, but I could not, reason that id of that email is now 'BBB'!
I checked it by pressing on that email in Outlook and calling this javascript code Office.context.mailbox.item.ItemId I found that email ID changed.
Question is how to make ID what is returned by Office.context.mailbox.item.ItemId constant so is the same in compose and in Sent status of the email?
In graph.api you have immutable ids but I do not see how to apply them in office.js.api
First of all, I'd recommend calling the Save method before retrieving the item Id. For example, the EntryID property available in the Outlook object model is set when an item is saved to the store.
Also different Outlook clients will return the itemId in the protocol they leverage. REST and EWS item Ids are escaped differently which is causing the difference between the itemId for the same item.
The id returned by Office.context.mailbox.item.itemId is an EWS item id. You can convert it to rest/graph item id by using Office.context.mailbox.convertToRestId.
In the desktop edition of Outlook the EntryId may be changed when an item is moved to another folder/store. Check it out whether this is the case.
Immutable ids are Graph specific. Ids in EWS (that is what JS addins use) and MAPI (used by both Extended MAPI - native Outlook API - and by the Outlook Object Model) change when an item is moved.
Your best option is to add your own custom property to the item and then search for it when the item in moved to a different folder.

Get Diagnostic Information from returned Email through OLE Outlook

How is it possible to get the diagnostic information from an email received in Outlook. We're using some ole thing in gupta/teamdeveloper. I want to find out if the email was returned by the system if the sender was not found because we're using the sent/received date and when that is empty (which apparently happens when the mail is returned by the system) our software crashes because the ole thing can't read the empty date...
Use the Outlook_ReportItem object which is similar to a MailItem object, and it contains a report (usually the non-delivery report) or error message from the mail transport system.
If you don't have it in your automation apl already, then you'll need to re-generate the apl.
All the functions you need will be in the Functional Class once the interface has been (re) generated properly.

Logic Apps Email Trigger - Get original Alias

Found a very similar question here: Email aliases not returned as "To" address in logic app
TLDR: From within a logic app "When a new email arrives" trigger, How do I get the original alias that the email was sent to?
I have a logic app that creates a ticket based off an email sent to an outlook box. Now I want to be able to choose aspects of the ticket based off of whether or not the email was sent to the mailbox itself or an alias of the mailbox. The problem I'm having is that by the time logic apps gets a hold of the email, the alias address has already been replaced with the actual box's address ("alias1#place.com" -> "actualbox#place.com").
The actual mail in the inbox has the original email's alias information in the headers, but I can only get them by looking at the properties in outlook. I've tried to get the original "To" internetheader information both within logic apps (by exporting the email to blob storage and looking at headers there) and with the Microsoft Graph API. Sadly, the email exported by logic apps doesn't have the alias information and Graph API has pretty much every header but "To". At least one other person has lamented the lack of To
That said, the actual email still has the original alias information. Can someone help me get that information in logic apps without jumping through too many hoops? A many hoop solution is welcome if none other can be found though.
Use the Export email (V2) action from the Office 365 Outlook connector. This will give you the full message with original headers (including the actual To address)!
The flow here is, trigger on the incoming email, as you already are, then add the export email action providing the message id from that trigger to pull this specific email.
From there, you you'll have one big "body" property which you'll need to interrogate to find the To address.
Caveat on this though, it doesn't work when emails are sent between mailboxes in the same Office 365 tenant. Exchange Online will "helpfully" go, "I know that address... this is the address you wanted!"
What API are you using? In Outlook Object Model / MAPI / EWS, you need to retrieve the PR_TRANSPORT_MESSAGE_HEADERS MAPI property (DASL name http://schemas.microsoft.com/mapi/proptag/0x007D001F)
We arrived at a many hoop solution.
The "Primary" email box now has some rules that look at the internet headers mentioned above (Message -> Properties -> look for 'To:').
If it finds an alias there, it will put the email in a corresponding folder for each alias.
Then we have logic apps listening to each of the alias folders which will then send the email's information to the _Core logic app that does the actual processing.

Outlook New Message - Text Area Below Toolbar

I am creating an addin for Outlook.
I want to check some text on sending, but im not sure how to reference it
The text is in the image below and says “Attachment will be sent using...”
If the text equals the text displayed, i want to do something.
Thanks for any advice.
The Outlook object model doesn't provide anything for reading mail tips. But you may consider using EWS for getting mail tips. See Using MailTips in EWS to get the OOF (Out of Office) Status of users with C# and Powershell for the sample code.
FYI MailTips are informative messages displayed to users in the infobar in Outlook Web App and Outlook 2010/2013/2016 when a user does any of the following while composing an e-mail message:
Add a recipient
Add an attachment
Reply or Reply all
Open a message from the Drafts folder that's already addressed to recipients
To configure MailTips for mailboxes, external contacts, and distribution groups, in the Exchange Control Panel, select the mailbox, external contact, or distribution group, click Details, and then in the MailTip section, create the MailTip.
To configure MailTips for mail users and dynamic distribution groups, in Windows PowerShell, use the MailTip parameter on the Set-MailUser and Set-DynamicDistributionGroup cmdlets.
Regardless of whether you use the Exchange Control Panel or Windows PowerShell, two things always happen when you add a MailTip to a recipient:
HTML tags are automatically added to the text. For example, if you enter the following text: This mailbox is not monitored. The MailTip automatically becomes the following: <html><body>This mailbox is not monitored.</body></html>
The text is automatically added to the MailTipTranslations property as the default value. If you modify the MailTip text, the default value is automatically updated in the MailTipTranslations property.
Read more about that in the Configure MailTips article.

Get/change safe senders list and blocked senders list in C# VSTO

I'm working on an Outlook 2010 add-in that needs to prompt users before following a link found in an email. During the process I'd like to offer the user the choice to trust or block the sender of the email, thus I need to access both lists. I realize that Junk/Spam email options are not exposed by Outlook OM. Although I was successful in accomplishing the task using Redemption, unfortunately I'm not allowed to use it by my employer, so I need to find another way. I found this post (Get Safe sender list in Outlook 2007 C# Add in) that points in the direction of either MAPI properties or registry keys.
My preference would be MAPI props, but I'm not sure what object that property belongs to. Would it be the property of the default store?
Outlook.Store obj = Application.Session.DefaultStore;
const string PR_SPAM_TRUSTED_SENDERS_W =
"http://schemas.microsoft.com/mapi/proptag/0x001f0418";
Outlook.PropertyAccessor pa = obj.PropertyAccessor;
string list= pa.GetProperty(PR_SPAM_TRUSTED_SENDERS_W).ToString();
Unfortunately I'm getting an error message (translated to English) like 'Object doesn't have such property'. In production it would have to work with Outlook clients connected to Exchange 2007 mailboxes.
Ok found it. The actual property is called PidTagExtendedRuleMessageCondition and the Blob format is described here MS-OXCSPAM and in MS-OXORULE respectively.

Resources