I'm using Microsoft.Exchange.WebServices.dll to read signed emails from an Exchange Server. Returned object's property Attachments contains either regular attachments or inline images from the email body.
In case the email has both (regular attachments, body with inline images), only regular attachments are listed in the Attachments. Inline images are completely missing.
Any idea on how to retrieve both, regular attachments as well as inline images in the body? Body property of the email has just the text part and no mention/reference there should be some images at all.
Related
I want to conert the mail document and attachments to pdf,
If there’s any text in the mail body along with the attachment then the mail content should be converted to pdf in the first page of the pdf, followed by the attachment (in the next page/s).
I am able to convert the mail body and attachment into seperate pdf's but not able to club them, in mail body as first page of pdf and attachments as other.
Please help.
I am using the Grails mail plugin to send emails and I want to send images in the body of the email, not as attachment. What I want is for images to be shown in the email body itself, as in newsletters. I tried:
img style="display:block; height:100px; width:100; " alt="candle"
src="http://www.xyz.com//Candle_4.jpg">
but it is being displayed as-is.
I also tried using the wikimedia format:
[[:File:Example.jpg]]<br/>
[[Special:FilePath/Example.jpg]]
but again, both seem to link to external.
What am I doing wrong?
This is the email template I am using:
<img src="cid:springsourceInlineImage" /> Dear [username],<br/>
Thank you for shopping with us.<br/>
You have placed a new order with following details.<br/>
[details]<br/>
Happy shopping!
But, if I want to put 10 images in my template, how would I do that?
You have to do three things
Declare mail as multipart
Attach your image as inline image
Reference you inline image from your mail template
According to this mailing list thread it should work like this:
sendMail{
multipart true
to "[hidden email]"
subject "Subject goes here"
html g.render( template: '/emails/mailTemplate')
inline 'springsourceInlineImage', 'image/jpg', new File('./web-app/images/springsource.png')
}
In your template you could refer the image like this
<img src="cid:springsourceInlineImage" />
Hope that helps.
In general, most "newsletter" type emails are just HTML emails and don't in-line the images within the body of the emails. In fact, many email servers will outright reject emails that are too big, and putting the image data inside the body of the email can easily run this risk.
Instead, the way to do with this is to just have HTML emails with the images you wish to include as normal HTML image links.
Please refer to the Mail plugin documentation for more info on how to send HTML emails.
Sorry I don't have enough Stackoverflow points to leave comment on others' answers.
In #aiolos 's answer, it contains:
inline 'springsourceInlineImage', 'image/jpg', new File('./web-app/images/springsource.png')
This specifies 'image/jpg' as the output, but the file is in png format. Is this intentional?
Wikipedia provides a list of mime types: http://en.wikipedia.org/wiki/Internet_media_type#Type_image
I tried 'image/png' and it worked, so I'm not sure if setting it to 'image/jpg' makes any difference.
My program uses MAPI for working with Exchange mailboxes. The problem is if a user fires up Outlook, adds a file as an attachment and also opens Paint, selects a region there, copies it into clipboard and pastes into the message body the resulting message showns two attachments.
More specifically, the program calls IMAPIMessage::GetAttachmentsTable() to retrieve the attachments table and that table contains two objects. Is there a way a program can decide whether the "attachment" is really an attached file or a portion of inline content?
You will need to check whether the HTML body (through the img tag) refers to the attachment, either through img:cid and PT_ATTACH_CONENTS_ID property or though the file name (PR_ATTACH_LONG_FILENAME) or contnet location (PR_ATTACH_COMTENT_LOCATION).
The property you are looking for is PR_RENDERING_POSITION (0x370B0003). A -1 means that the attachment is a "normal" attachment and not in-line. If the value is anything other than -1, then that indicates an in-line attachment and the value is the position in the body that the attachment should be rendered at.
Here is the MSDN page describing it.
EDIT:
Dmitry, I do not agree with your comment. I have HTML email messages with in-line attachments and the PR_RENDERING_POSITION is working as described in the MSDN page I posted.
I am trying to read mails programmatically in VB6. but i am unable to read mails containing inline images or HTML code like hyper link. Can anyone suggest me the way to read this type of mails.
EDIT:
I am not getting any error message but
nsfDocument.GETITEMVALUE("Body")(0) returns only text.
images are not shown.
You may want to try a third party API to help, such as the Midas Rich Text C++ API from Genii Software. http://www.geniisoft.com/showcase.nsf/MidasCPP
Or try the code examples shown on this site to gain access to the Notes Document in HTML form: http://searchdomino.techtarget.com/tip/0,289483,sid4_gci1284906,00.html
The GetItemValue method of the Document class returns rich-text item values as an array of strings, with all rich text styling removed. The "body" field in a Notes email is generally rich text. So, you should look into using the GetFirstItem method, instead. That will return a NotesRichTextItem object (for the body field). From that object, you can access the styling of the text, hyperlinks and file attachments, etc. (I do not believe that you can access in-line images at all via the "back-end" COM classes - I think for that, you will need to drop down to use the C API classes).
Here's a quick sample of how to get a NotesRichTextItem handle:
Dim doc As NotesDocument
Dim rtitem As Variant
... get the document
Set rtitem = doc.GetFirstItem( "Body" )
If rtitem.Type = RICHTEXT Then
.. work with rtItem
End If
Here is the doc page for the NotesRichTextItemClass:
http://publib-b.boulder.ibm.com/lotus/c2359850.nsf/2e73cbb2141acefa85256b8700688cea/dc72d312572a75818525731b004a5294?OpenDocument
And here is a starting point for the C API docs:
http://www14.software.ibm.com/webapp/download/nochargesearch.jsp?k=ALL&S_TACT=104CBW71&status=Active&q=Lotus+%22C+API%22
I have a Yahoo pipe taking the Atom feed from a Google group, and I want to do some processing on the message's full text (running various regular expressions to extract data). I can get a message's text in plain text from from Google using a url like this:
http://groups.google.com/group/(group_name)/msg/(message_id)?dmode=source&output=gplain
However, I'm having trouble getting it inside Yahoo pipes as a string value. Fetch Page rejects non-HTML pages. YQL using the html table seems to work, and wraps the plain text inside a p element, whose text I can extract like this:
select * from html where url="..." and xpath="//p"
However, if the message text contains html tags, YQL returns an HTML subtree instead of a string. Is there any way of flattening it back into its HTML source?
The trick is to remove the "output=gplain" and grab the content from the pre element.
select content from html
where url="http://groups.google.com/group/haml/msg/0f78eda2f5ef802d?dmode=source"
and xpath='//div[contains(#class,"maincontbox")]/pre'
I have created a pipe with Google Group and Message ID as inputs to demonstrate:
http://pipes.yahoo.com/pipes/pipe.info?_id=3d345e162405e7dbd47d73b95c21f102