How to know if attachment is a signature in an Outlook email - c#

I have an Outlook email and I need to process it's attachments. But when iterating through the attachments, if the attachment is a signature I want to skip it.
To know if the attachment is a signature I am using:
outlookMailItem.Attachments[i].PropertyAccessor.GetProperty(
"http://schemas.microsoft.com/mapi/proptag/0x3712001E");
But I am getting an Outlook security alert.
Is there another way using a safer code? Can it be done using Redemption?

PR_ATTACH_CONTENT_ID property is a good indication that an attachment is an embedded image, but there are attachments that have PR_ATTACH_CONTENT_ID property set, but they are not embedded images (Lotus Notes likes to set PR_ATTACH_CONTENT_ID on all attachments).
Even if PR_ATTACH_CONTENT_ID is not set, Outlook can use PR_ATTACH_CONTENT_LOCATION or PR_ATTACH_LONG_FILENAME to load an embedded image.
The only real test is to parse the HTML body and figure out which <img> tags refer to the attachments.
Redemption (I am its author) will let you access that property using RDOAttachment.Fields, you can also use RDOAttachment.Hidden property, which jumps through a few hoops to figure out whether an attachment is an embedded image and not a "real" attachment.

RDOAttachment.Hidden property works well only if the email format is HTML. For emails in Rich Text Format, the signature image would be treated as any other attachment and will have this value as false. A better bet would be to use "Attachment.Type", which works for both HTML and Rich Text. For signature, it would always be olOLE and for other attachments, it would be olByValue. So, you can filter the signature images using this property. However, note that, if the email format is Rich Text and if you have a screenshot embedded within the email, it's treated as olOLE type.

Related

Copy List to clipboard for rich text pasting into Outlook

I have a list made up of three pieces: Text, url, long text (basically, it's a twitter handle, link to the tweet, text of the tweet).
I'm trying to figure out how to load that list into the clipboard so that when you paste it into standalone Outlook (or OneNote, I'm presuming it'll be the same solution), you end up with a clickable link made out of the first two pieces of data (ie MyHandle is an <a href to the tweet).
You could copy formatted HTML string into a Clipboard for paste using the below code:
HtmlFragment.CopyToClipboard(insertString);
selected.Paste();
Reference :
How do I copy formatted HTML string into a Clipboard for paste using C#?
Alina's answer was correct, but I do agree with Rob about it needing more information.
Basically, there isn't a way to do it directly, however, in How do I copy formatted HTML string into a Clipboard for paste using C#? there's a reference to the HTMLFragment Class at http://blogs.msdn.com/b/jmstall/archive/2007/01/21/sample-code-html-clipboard.aspx. That Class, called by HtmlFragment.CopyToClipboard(insertString); does still happen to work for pasting formatted text into Outlook/OneNote.
Looking at the original code, Clipboard.SetText(insertString, TextDataFormat.Html);, I should have tested that first since the original post was erroring on the paste, not the Clipboard set, but, in the end, the HTMLFragement class works so, I'm happy. It's just a project for a single person so it was a bit of half-arsedness (not a lot of error checking or beauty in the ui.. I mean, heck, I did it as a winform rather than fluent/uwp). But, that's the answer:
Try Clipboard.SetText(insertString, TextDataFormat.Html); and if that doesn't work when you attempt to paste into the clipboard, move head into the HTMLFragment Class in http://blogs.msdn.com/b/jmstall/archive/2007/01/21/sample-code-html-clipboard.aspx and call it via HtmlFragment.CopyToClipboard(YOUR_HTML_STRING);

Send RTF in a HTML body by email C#

We have an C# application which sends emails to clients. In these emails can be information about several things and this information can contains a note.
Example email:
Person: John
Age: 35
Note: He works as developer.
(Jonn's picture)
(Excel table)
Person: Mary
Age: 40
Note: (Another picture)
bla bla bla
Until now, we extracted the plain text of the note, but now we want to send the whole note (it is written in rtf format and it can contain images, excel tables and so on).
The email body is made in HTML and can contain several notes.
Does someone know what will be the best option to add these notes to the email? Is it that possible? because the body is a HTML document and I have to add several notes... Maybe is it easier as image (try to get an image from the rtf)? or is it better in HTML?
I hope you can help me or guide me.
Thank you in advance.
Regards.
Definitely its possible. I did similar sort of thing. First read RTF contents into a string (say rtfContent) by using InputStreamReader, then pass this string to a method ConvertRtf2Html(rtfContent). You can follow this link to download the project which converts RTF content to HTML and much(I don't know all the functionality, as I used only ConvertRtf2Html() method)

Mailto does not invoke outlook in chrome.

In view I rendered two links that have mailto. Both of them have body attributes passed to mailto. One has short body text, other very long. When I click on link that has shorter body, it works and outlook opens. Link with longer body does not work (I clicked and nothing happens). But that happens only in chrome. In other browsers both links work. I noticed that in Chrome page source longer body text is made shorter with some notation. This might be the issue.
Does anyone know how to solve this problem? Any help would be appreciated.
Checking for spaces (and removing them) between the colon and the recipients, and between multiple recipients.
Variables that can be used with mailto:
mailto: set the recipient, or recipients, separate with comma
&cc= set the CC recipient(s)
&bcc= set the BCC recipient(s)
&subject= set the email subject, URL encode for longer sentences, so replace spaces with %20, etc.
&body= set the body of the message, including line breaks. Line breaks should be converted to %0A.
A MailTo Generator can be found here.

Format the body of the outlook appointment item

I am trying to create an outlook appointment from an ASP.NET web site version 2.0. I am making use of the interface Microsoft.Office.Interop.Outlook to create the appointment. But my exact requirement is to display the body (description) of the appointment in HTML format (which includes images, links etc) instead of plain text. The only method
I can see in the appointmentItem is ‘body’. This method only writes the plain text not the formatted HTML body.
So is there any alternate approach to format the description (body) of an appointment? Please help me out with this.
Did you tried something like
.Body = "{\rtf1\ansi\deff0{\fonttbl{\f0 Arial;}}{\colortbl ;\red0\green0\blue255;}\pard\cf1\f0\fs24 Test}"
Source : http://www.xtremevbtalk.com/archive/index.php/t-91618.html

Stop Auto-hyperlink in Outlook, Gmail etc

My web application sends emails to users. The email contains a link for further user action. Our security standards require that the link in the email cannot be clickable. However, the email clients recognize https:// in the email and auto-link the URL.
Any idea on how to stop the email clients to auto-link. I am thinking if I skip the https://, it may stop the auto-linking. But, if I have to keep the https:// is there any way to avoid auto-linking.
The link in the email is dynamically constructed in the c# code.
I know this thread is old, but I just had this issue myself, and wasn't thrilled by the gif image fix. If you're working with HTML emails, a slightly nicer solution is to break up the link text with a non-rendering tag that tricks the parser. I'm a fan of a simple non-existant <z>:
https<z>://securesite.</z>com
It even works in Stack Overflow posts: https://securesite.com.
Hope this helps someone.
I too wish to disable this, as I believe this is a "valid" use as to not wanting auto-linking (one reason is the designer wants it that way, and they are currently paying the bills).
In email sent that has no images, the header has the domain name in it:
EXTRANET.EXAMPLE.COM
I even put inline styles to make sure it stays white on a black background:
<span style="font-size: 1.5em;padding: 0.5em 0;text-transform: uppercase; font-weight:bold;color:#FFFFFF;text-decoration:none;">EXTRANET.EXAMPLE.COM</span>
Gmail makes this a link, adds an underline and also turns it bright blue instead of the intended white.
At first I tried replacing the dots with . which made it look fine, but didn't fool the Gmail parser.
So, I added a spanned space which work just fine (i.e. it fools Gmail's parser):
<span style="font-size: 1.5em;padding: 0.5em 0;text-transform: uppercase; font-weight:bold;color:#FFFFFF;text-decoration:none;">EXTRANET<span style="font-size:0.1em"> </span>.<span style="font-size:0.1em"> </span>EXAMPLE<span style="font-size:0.1em"> </span>.<span style="font-size:0.1em"> </span>COM</span>
Just create a plain <span> tag around the colon (<span>:</span>) or something like that :)
Replace the actual text with a small GIF image that looks like text.
Email parsers will not recognize text within an image.
My application has a similar security requirement. The solution we used was to add an underscore to the beginning of the URL (_http://).
Sorry to dredge up an old question, but I just tried the answer suggested by pieman72, and found that it didn't work within Outlooks 2007–2013. However, wrapping the individual elements of the URL within table cells did fool the Outlook parser:
Visit <table><tr><td>www.</td><td>website</td><td>.com</td></tr></table> for more information.
I ran a sample message through the Email On Acid test suite and found that it eluded the parser on all the major e-mail clients which automatically convert URLs (Outlook, iOS, Android 2.2, etc.) I did not run any deliverability tests.
#raugfer suggests in another answer: wrap the email/URL with an anchor.
<a name="myname">test#email.com</a>
Quoting from that answer:
Since the text is already wrapped in a hyperlink, Gmail gives up and
leave it alone. :)
(Note: also worked for Apple mail client.)
Necroing the question, I know, but it's relevant... I'd like to present a reasonable scenario where Gmail's auto-linking (at least - haven't tested other clients) doesn't make sense.
A client has an application form on their site, where visitors fill out some personal information and submit it. The system then sends a notification email to the client, presenting the information the visitor supplied.
I'm wanting to enhance the email sent to the client by adding a <textarea> at the bottom, with the fields the visitor filled out presented in CSV format so that the client can simply copy it all and paste it into a spreadsheet.
Gmail, however, fails to recognize that the URLs and email addresses are inside a <textarea> tag, and "helpfully" adds the ... link code around the URL/email - inside the <textarea>. This results in the raw HTML link code showing up in the <textarea>.
This is what i did:
Replace all instances of "." with <span style=""color:transparent; font-size:0px;"">[{</span>.<span style=""color:transparent; font-size:0px;"">}]</span>
Replace all instances of "#" with <span style=""color:transparent; font-size:0px;"">[{</span>#<span style=""color:transparent; font-size:0px;"">}]</span>
These characters stopped it parsing links and email addresses, but aren't visible to the user. The negative is that when you copy and paste an email for example, you end up with: "test1{[{.}]}domain{[{.}]}com"
.

Categories

Resources