When I use COM API to get the Body of MailItem Object on some Japanese environment Outlook client, sometimes the content of Body would be unreadable. And it shows that, Outlook sends the content string to COM component by ANSI encoding (Shift-JIS), but COM API expected Unicode (2-bytes length) encoding and the mail body really is encoding by Unicode when I view the source of the mail. After I restart the Outlook client, the problem just could not be reproduced on the same email. Why does Outlook sometimes convert the encoding of email body to ANSI, and most of time not ?
Also when Outlook convert the Unicode content to ANSI (It should not be, as the mail source is Unicode encoding) and send it back to COM invoker, the Body of MailItem shows some html elements, is it a bug of Outlook?
Related
I am looking for a way to get structured email headers from Outlook and process them in Power Automate Desktop.
Assumptions
You can retrieve email headers in Outlook by using the following URL
https://support.microsoft.com/en-us/office/view-internet-message-headers-in-outlook-cd039382-dc6e-4264-ac74-c048563d212c
The Challenge
The mail headers obtained from the client application Outlook are in text format and very difficult to handle.
Constraints
We assume that we are parsing mail headers from an attached .msg file.
It is not possible to retrieve mail headers in json format using the Graph API.
Fortunately, Power Automate Desktop supports execution of VB script, JavaScript, Powershell, and DOS commands. It may be possible to take advantage of these to turn text into Json format, etc.
If you can use Outlook Object Model in VBS, you can retrieve MIME headers from a received message by reading the PR_TRANSPORT_MESSAGE_HEADERS MAPI property using MailItem.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x007D001F")
Is it possible to download email body and attachments in a file in .MSG format in Outlook Web? I am working on an Outlook 365 Web addin and I require to download entire message along with attachments in .MSG format?
Edit: Is there any open source library in .NET which does the same?
Thanks,
I have to do the same thing, but since the company I'm writting the addin for is using a version of Windows/MSOffice where the webview that the addin runs inside is handled by a IE11 process, I got OOM-error when trying to download an attachment bigger than 7MB via a EWS request (using the ews-javascript-api).
Now I'm using a IIS server to which I send the eschangeToken and EmailId and handle the download/upload of the email there via EWS-managed-api from MS.
Downloading the email as .MSG is not possible AFAIK, I download them by getting the MIME-content of the email and saving it as an .EML file.
Here MS provides some examples on how to use the ews-managed-api.
EWS cannot convert to MSG. You can try to save in the Fast Transfer Stream format using the ExportItems EWS operation (which, just like the MSG format, preserves most properties). The EML format, on the other hand, will not preserve MAPI specific properties. The FTS data can then be converted (without any loss of fidelity) to the MSG format using Redemption (I am its author - RDOSession.CreateMessageFromMsgFile / RDOMail.Import(..., olFTS) / RDOMail.Save), but since Redemption is a native COM library, that code would have to run on your server, not inside the browser.
RDOSession session = new RDOSession();
RDOMail msg = session.CreateMessageFromMsgFile(#"c:\temp\test.msg");
msg.Import(#"c:\temp\test.fts", rdoSaveAsType.olFTS);
msg.Save();
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.
I am trying to send a rich text message via Twilio. I am able to send regular SMS messages, but I want to include a hyperlink in the body of the text.
I tried the twilio mediaUrl to include an rtf file, but that didn't work. Including html in the body of a message doesn't work as it just sends in plain text.
I'm posting via curl to the twilio endpoints, so i'd prefer not to have to get into PHP or some other language to achieve this. I just want to send raw data to twilio and receive a rich text message back, if it's possible.
Twilio developer evangelist here.
Using Twilio you can send MMS messages to numbers in the US and Canada. When you pass a mediaUrl the file needs to be hosted somewhere publicly on the web and it will then be included within the message.
You can pass files of any of the mime types listed here, though when sending RTF the result will depend on how well the receiving device supports RTF files.
If you want to include a link, I'd recommend shortening the URL (using bit.ly or similar) and just sending it as part of the text. Most smart phones will auto link the URL. Built in SMS apps on phones don't support markup of any sort, which is why your attempt with HTML just showed the raw markup.
Let me know if this helps at all.
I am trying to send a report from Exchange Management Shell Exchange 2007. When I send this report to Outlook the email is formatting as expected, but when I send the email to Lotus it's losing the HTML formatting such as CSS, headings, tables and borders. The data is preserved but the formatting is incorrect.
On the other hand, when I send the message using Send-MailMessage in Exchange 2010 everything is fine even when I send it to a Lotus Notes user.
Why does this difference occur?
You're going to have to go to the Notes client, and view the MIME source of both messages and compare them using a good diff program. If one is displaying correctly, and the other is not, there will be differences, and finding out why and those differences occur should give you some clue about what is happening to break the message.
(The above is assuming that the recipient is set up to receive the message in his mailbox in MIME format. If, in fact, the user has been set up to receive messages converted to Notes rich text format, then you would have to go to the Domino server instead of the Notes client, and use the SMTPSaveImportErors setting to capture the MIME source for the two messages.)