I was trying to manipulate the html code of the subject line like that:
I am subject#001
But the subject line can not HTML. Is there any other way I can hyperlink a word in the subject line?
No, you cannot.
HTML markup in mail headers is not supported by any email specification. Therefore, no, you cannot hyperlink a word in the subject line.
You cannot, put if you put a link in the subject (starting with http:// or https://), Outlook will show it as a link.
Related
I have a requirement to have a link on a webpage that users can click on a link that will open a Microsoft Outlook window that has the To, Subject, and Body fields pre-populated with information pertinent to the request.
The Subject and Body Fields are covered, but I need to populate the To field with data that is generated in my C#. The easiest way that I know of to do this, would be able to create an asp hiddenField, and populate it with the e-mail addresses that I need separated by semicolons. The problem is that I don't know how to get the actual text of the field to show up in my href. The code below describes it:
Email
If there is a better way to accomplish this than through an asp hiddenField, please let me know. I'm new to web design programming, so my knowledge is limited. Thanks!
I'd use the Hyperlink-control if i want to access it on serverside.
<asp:HyperLink id="hyperlinkEmail" Text="Email" runat="server"/>
and in codebehind:
string href = string.Format("mailto:{0}?Subject={1}&Body={2}"
emailAddress, subject, body);
this.hyperlinkEmail.NavigateUrl = href;
I'm trying to replace some text in the body of the email, but whenever I do it seems to screw up the formatting of the signature text. For example, if I try email.Body.Replace("Info", "Information") then this text:
First Last Title Info
Website: www.stackoverflow.com
turns into:
First Last Title Information Website: HYPERLINK
"http://www.stackoverflow.com/"www.stackoverflow.com
This happens even with just a simple addition to the text like email.Body += "text".
Along with this, it also switches the font of the body from Arial 10 to Calabri 12 (this probably has to do with Calabri 12 being the default email text when Arial 10 is the signiture font).
How would I save the format of the current email body so that when I add text to it, I could set it back or what would be the best way to add text to the body to keep the formatting?
Your help would be welcomed.
MailMessage.Body can be formatted in RTF, which I think it does by default, or in HTML. What the top message you posted actually looks like is something like this:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\colortbl ;\red0\green0\blue255;}
{\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\sl240\slmult1\lang9\f0\fs22 First Last \par
Title \par
\par
Info \par
Website: {\field{\*\fldinst{HYPERLINK "www.stackoverflow.com"}}{\fldrslt{\ul\cf1 www.stackoverflow.com}}}\f0\fs22\par
}
I'm assuming that appending "text" to the end of that is causing the RTF message to be parsed improperly, resulting in a loss of formatting.
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.body.aspx
So, what I ended up doing was using the email.HTMLBody. I created a paragraph block similar to what the HTML already had. This is the block: (my HTML isn't very good so... a lot of if is copy/paste with some editing)
<p class=MsoNormal>
<b>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Replace Text
</span>
</b>
</p>
I set this to a string, say htmlPar, then do a replace:
string htmlReplace = htmlPar.Replace("Replace Text", myNewText");
This will create a paragraph block that I can add to the HTML with whatever my text is. To actually add it to the end of the HTMLBody I do a string.Replace like so:
string temp = email.HTMLBody.Replace("</body></html>", htmlReplace + "</body></html>");
email.HTMLBody = temp;
With this I was able to keep the formatting in the rest of the email. Like I said, my HTML isn't great so I'm not sure if this could work to add text in general or how good of a method doing it this way actually is.
Either way, I hope this can help someone else down the road.
I've run into a little problem. Im making an Outlook Add-in, where i can archive an email.
When an email contains html/xhtml etc it converts hyperlinks into HYPERLINK "url".
Example:
HYPERLINK "Company URL" 1 x Mexicano
HYPERLINK "Company URL" € 1,75
HYPERLINK "Company URL" 1 x Patat
HYPERLINK "Company URL" € 1,25
each line should be an clickable URL, but for some reason outlook doesnt give plain text but this instead...
So i want to strip my string from: HYPERLINK "any characters here"
Can someone help me with this?
You can use something like:
Regex regex = new Regex ("HYPERLINK \"(.*?)\"");
This will match Company URL in HYPERLINK "Company URL" 1 x Mexicano, if that's what you were looking for.
I am working on an application that involves the user clicking on a hyperlink to popup an outlook email template. I have the SendTo values, and the subject values.
How do I enter text into the body of the email?
In the hyperlink you can add the ?body= variable after the email address. Formatting the body will be a challenge because for symbols like spaces you have to use hex codes (space = %20, newline = %0D). I don't know what your design criteria are, but most of the time I prefer to create a form with the desired input fields and let .NET handle the sending of the e-mail message on the submit.
Are you searching for this?
...
Using MailMessage email = new MailMessage();email.IsBodyHtml = true;
Is it possible to set the font for the message?
Also, maybe it's a quirk but p and br tags come out the same for me? Is this normal?
You can use CSS:
<style>
p {color:#999; font-family:arial;} /*grey*/
</style>
You are limited to what fonts are install on the receivers machine.
I would suggest researching using a style sheet attribute to change the font size.
Not sure what you mean by the 'and tags come out the same for me' part... come out the same as what?
...charles beat me to it
When dealing with HTML email's you will find a multitude of frustrations.
Some issues I can remember
Some mail clients won't render CSS when it is placed outside the <body> element.
Some mail clients won't render CSS at all.
A great resource for HTML email is email-standards.org
You can include css in body of mail. Since mail body is in html format, all html features can be used here.
No, break and paragraph tags are not the same.
Break just starts on a new line, paragraph adds some space around it. They also cause floating objects to behave differently around them.
They can also be styled independently using css.