I have a web application which notifies customers of their application status via email. Standard email messages are uploaded through a user web page. And is stored in a SQL server db table. The email web service then reads the message content from the db table, converts it to string and triggers the email.
System.Data.SqlClient.SqlDataReader Msg = RC.dbTable("EmailMessage", parm);
if (Msg == null)
{
returnString = "Error Sending Email->" + RC.ErrorMessage("Error Getting Standard Email Message->");
}
else
{
if (Msg.Read())
{
msg = Msg["MessageContent"].ToString().Replace("[", "<").Replace("]", ">");
topic = Msg["MessageTopic"].ToString();
}
Msg.Close();
}
This time, I had to include some bullet points in my email so I created the email message in word, saved it as HTML file and uploaded it to the web page. The email message shows up perfectly in any browser.
Hello,
Please reply to xyz#abc.com with the following:
‐ a paper
‐ a pen
‐ a file cover
This needs to be completed.
Stay Safe.
But, when I tested the email functionality, I am getting the email like this:
Hello,
Please reply to xyz#abc.com with the following:
‐ >>a paper
‐ >>a pen
‐ >>a file cover
This needs to be completed.
Stay Safe.
I don't understand why is the email message has >> in the bullet points text. Please find below the HTML file snippet.
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 15">
<meta name=Originator content="Microsoft Word 15">
<link rel=File-List href="Hello_files/filelist.xml">
<link rel=themeData href="Hello_files/themedata.thmx">
<link rel=colorSchemeMapping href="Hello_files/colorschememapping.xml">
<style>
</style>
</head>
<body lang=EN-US link="#0563C1" vlink="#954F72" style='tab-interval:.5in'>
<div class=WordSection1>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Verdana",sans-serif'>Hello, <br>
<br>
Please reply to </span><a
href="mailto:xyz#abc.com"><span style='font-size:12.0pt;font-family:
"Verdana",sans-serif'>xyz#abc.com</span></a><span style='font-size:
12.0pt;font-family:"Verdana",sans-serif'> with the following:<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Verdana",sans-serif'><o:p> </o:p></span></p>
<p class=MsoListParagraphCxSpFirst style='margin-bottom:8.0pt;mso-add-space:
auto;text-indent:-.25in;line-height:105%;mso-list:l0 level1 lfo1'><![if !supportLists]><span
lang=EN-CA style='font-size:12.0pt;line-height:105%;font-family:"Verdana",sans-serif;
mso-fareast-font-family:Verdana;mso-bidi-font-family:Verdana;mso-ansi-language:
EN-CA'><span style='mso-list:Ignore'>‐<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]><span lang=EN-CA style='font-size:12.0pt;
line-height:105%;font-family:"Verdana",sans-serif;mso-ansi-language:EN-CA'>a paper<o:p></o:p></span></p>
<p class=MsoListParagraphCxSpMiddle style='margin-bottom:8.0pt;mso-add-space:
auto;text-indent:-.25in;line-height:105%;mso-list:l0 level1 lfo1'><![if !supportLists]><span
lang=EN-CA style='font-size:12.0pt;line-height:105%;font-family:"Verdana",sans-serif;
mso-fareast-font-family:Verdana;mso-bidi-font-family:Verdana;mso-ansi-language:
EN-CA'><span style='mso-list:Ignore'>‐<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]><span lang=EN-CA style='font-size:12.0pt;
line-height:105%;font-family:"Verdana",sans-serif;mso-ansi-language:EN-CA'>a pen<o:p></o:p></span></p>
<p class=MsoListParagraphCxSpMiddle style='margin-bottom:8.0pt;mso-add-space:
auto;text-indent:-.25in;line-height:105%;mso-list:l0 level1 lfo1'><![if !supportLists]><span
lang=EN-CA style='font-size:12.0pt;line-height:105%;font-family:"Verdana",sans-serif;
mso-fareast-font-family:Verdana;mso-bidi-font-family:Verdana;mso-ansi-language:
EN-CA'><span style='mso-list:Ignore'>‐<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]><span lang=EN-CA style='font-size:12.0pt;
line-height:105%;font-family:"Verdana",sans-serif;mso-ansi-language:EN-CA'>a file cover<o:p></o:p></span></p>
<p class=MsoListParagraphCxSpLast style='margin-top:0in;margin-right:0in;
margin-bottom:8.0pt;margin-left:38.7pt;mso-add-space:auto;line-height:105%'><span
lang=EN-CA style='font-size:12.0pt;line-height:105%;font-family:"Verdana",sans-serif;
mso-ansi-language:EN-CA'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:12.0pt;font-family:"Verdana",sans-serif'>This needs to be completed.<o:p></o:p></span></p>
<p class=MsoNormal style='mso-margin-top-alt:auto'><span style='font-size:12.0pt;
font-family:"Verdana",sans-serif'>Stay Safe.<o:p></o:p></span></p>
</div>
</body>
</html>
Oh. MS Word was used to create the html. Hmm. Yes, it always makes a bit of a mess with all its crazy stylesheeting and masses of extra tags and other superfluous structure. You'd probably have a good result by just cleaning up the html to the minimum you need, which looks really simple - maybe 3 p and an ul, but I think the problem comes because of this:
msg = Msg["MessageContent"].ToString().Replace("[", "<").Replace("]", ">")
Plus these in the html:
lfo1'><![if !supportLists]><span
...
<![endif]>
Running that replacement will generate HTML that contains <!<endif>> which is definitely invalid html. Just because a browser can see it and not choke on it doesn't mean an email program will behave the same; you're putting garbage in and you're getting garbage out
Clean up the HTML:
<html>
<body style='font-face: sans-serif'>
<p>Hello,</p>
<p>Please reply to xyz#abc.com with the following:</p>
<ul>
<li>a paper</li>
<li>a pen</li>
<li>a file cover</li>
</ul>
<p>This needs to be completed.</p>
<p>Stay Safe.</p>
</body>
</html>
And don't do that replacement of square brackets with angle ones. It's asking for trouble
Related
to avoid downloading a tun of photos i was queries if i can target that photo by using the redirector that google makes for an image
the data I get
https://www.google.com/url?sa=i&url=https%3A%2F%2Fjessehouwing.net%2Fcommunity-effectively-use-stackoverflow%2F&psig=AOvVaw0WL94ed2XmYCHZQIVS_aqK&ust=1674303387408000&source=images&cd=vfe&ved=0CA8QjRxqFwoTCOiSsqeQ1vwCFQAAAAAdAAAAABAQ
<html lang="en-GB">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Redirect Notice</title>
<style>body,div,a{font-family:arial,sans-serif}body{background-color:#fff;margin-top:3px}div{color:#000}a:link{color:#4b11a8;}a:visited{color:#4b11a8;}a:active{color:#ea4335}div.mymGo{border-top:1px solid #dadce0;border-bottom:1px solid #dadce0;background:#f8f9fa;margin-top:1em;width:100%}div.aXgaGb{padding:0.5em 0;margin-left:10px}div.fTk7vd{margin-left:35px;margin-top:35px}span.fZSzqb{color:#ea4335}</style>
</head>
<body>
<div class="mymGo">
<div class="aXgaGb"><font style="font-size:larger"><b>Redirect Notice</b></font></div>
</div>
<div class="fTk7vd">
The page you were on is trying to send you to https://jessehouwing.net/community-effectively-use-stackoverflow/.<br><br> If you do not want to visit that page, you can return to the previous page.<script nonce="lmfZcvF7abRxtGG7ImyaXQ">(function(){var id='tsuid_1';(function(){document.getElementById(id).onclick=function(){window.history.back();return!1};}).call(this);})();(function(){var id='tsuid_1';var ct='originlink';var oi='unauthorizedredirect';(function(){document.getElementById(id).onmousedown=function(){var b=document&&document.referrer,a="encodeURIComponent"in window?encodeURIComponent:escape,c="";b&&(c=a(b));(new Image).src="/url?sa=T&url="+c+"&oi="+a(oi)+"&ct="+a(ct);return!1};}).call(this);})();</script><br><br><br>
</div>
</body>
</html>
ive look to see if i can find the image like inside the http but hade no luck
I need something like https://upload.wikimedia.org/wikipedia/commons/thumb/a/a6/Logo_NIKE.svg/330px-Logo_NIKE.svg.png
ive tried looking through the http string but it is out of my understanding and would like to know more.
I am working on automating an area of a web page (not able to provide the webpage as the contents are confidential, although will try to give as much insight as possible).
This element has on it an html code preview that will change after some selections are done. Here is the page html of the element:
<div _ngcontent-hje-c241="" class="field" style="position: relative;">
<pre _ngcontent-hje-c241="" class="code-pre">
"
<!doctype html>
<html>
<head>
<meta charset='utf'>
<title></title>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<style type='text/css'>body,html, #video {height:100%;margin:0;overflow:hidden;background-color:#000;}</style>
<script type='text/javascript'>
window.onload = function(event) {
var config = {containerID: 'video', Player: true, wmode: 'direct'};
myplayer = new Test.embed('WmAl', config);
}
</script>
</head>
<body>
<div id='video'></div>
</body>
</html>"
(I have edited and removed any confidentials parts of the string for the html, the html itself was not changed.)
I would need to get the value of the element I found through class="code-pre".
Here is what I have tried:
IWebElement htmlTest = driver.FindElement(By.ClassName("code-pre"));
var defaultHtmlTestValue = htmlTest.GetAttribute("value");
Assert.IsFalse(htmlTest.Equals(defaultHtmlTestValue), "The html has not changed after the Http selection");
The assert passes, altho, i would like to see what is the value that is being taken, as i feel like is not taking the html example i am trying to get.
I have also used Debug.Writeline(htmlTest) to see if it worked, but i got "Internal error in the expression evaluator". This is also an issue i will be trying to fix.
I am quite new to automation and stack overflow. Please let me know if there is a way i can improve this post.
I haven't worked with the html previews but looks like the whole html code is just the inner text of an element with class code-pre.
try doing :
String htmlTest = driver.FindElement(By.ClassName("code-pre")).getTex();
System.out.println(htmlTest);
Assert.assertTrue(htmlTest.Equals(defaultHtmlTestValue), "The html has not changed after the Http selection");
You can easily convert above java code into your language.
MVC 4, c#.net
sending emails using ActionMailer.Net.Mvc.EmailResult
using smtp server
using:
_email_layout.cshtml
<!DOCTYPE html>
<html>
<head></head>
<body>
<img alt="header.png" src="cid:header.png" />
<div id="main">
#RenderBody()
</div>
</body>
</html>
in MailController.cs
ActionMailer.Net.Attachments.Inline.Add("header.png", System.IO.File.ReadAllBytes(System.Web.HttpContext.Current.Server.MapPath("~/Content/Images/pic.png")));
ActionMAiler.Net.Mvc.EmailResult v = Email("myemailview", modelforview);
Sending email with:
myEmail.DeliverAsync();
If sent to our company emails - image is shown in the email as expected.
If sent to gmail.com - inline pic.png is not in email.
Instead there is kind-of place holder with "header.png" next to it and garbage text at the end of email.
Is it possible to see how to see html body of resulting email ?
Where is it in EmailResult object ?
Any ideas why inline image does not go through to outside emails?
Many thanks
how come the apostrophe always shows up as an ascii on the webchat control? it is properly rendered on the test page of the qnamaker. see attached codes and pictures.
this is how i add it on the qna maker knowledge base:
\n\n\t •Please check your computer's power cord.
QNAMaker Test Page:
however when i test it on the webchat control it appears like this.
using asci code instead of the apostrophe also wont fix the problem.
If you setup your bot likes the following in web client side:
<!DOCTYPE html>
<html>
<head>
<link href="https://unpkg.com/botframework-webchat/botchat.css" rel="stylesheet" />
</head>
<body>
<div id="bot"/>
<script src="https://unpkg.com/botframework-webchat/botchat.js" </script>
<script>
BotChat.App({
directLine: { secret: direct_line_secret },
user: { id: 'userid' },
bot: { id: 'botid' },
resize: 'detect'
}, document.getElementById("bot"));
</script>
</body>
</html>
Add the following line in the head to modify the charset:
<meta http-equiv="content-type" content="text/html; charset=utf-8"></meta>
I found this problem to happen on macs, not pc. My solution was to add this into my utterance sanitizer that would replace certain characters and therefore allow the Bot to handle it as expected
I started learning asp.net (I think the webpages not webforms, razor thingy? :) )
Ok I'm a complete noob, but anyway, I've been looking online and I've seen this question asked multiple times but none of the answers are helping me. I'm following a tutorial and I'm trying to do what its saying but when I run the code.cshtml it just displays the code in a webpage... I know there's gotta be some setting I have to fix or something but I don't know where that is.
my question is, how do I get a web browser to display an x.cshtml file? (I'm using microsoft visual web developer, but I also tried it using notepad and uploading the file to my website, still no good)
I forgot to add, using visual web developer gives me the following errors and wont run:
Error 1 Keyword, identifier, or string expected after verbatim specifier: #
Error 2 A namespace cannot directly contain members such as fields or methods
Error 3 Identifier expected line 8
heres the code
#
{
var total = 0;
var totalMessage = "";
if(IsPost) {
// Retrieve the numbers that the user entered.
var num1 = Request["text1"];
var num2 = Request["text2"];
// Convert the entered strings into integers numbers and add.
total = num1.AsInt() + num2.AsInt();
totalMessage = "Total = " + total;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Add Numbers</title>
<meta charset="utf-8" />
<style type="text/css">
body {background-color: beige; font-family: Verdana, Arial;
margin: 50px; }
form {padding: 10px; border-style: solid; width: 250px;}
</style>
</head>
<body>
<p>Enter two whole numbers and then click <strong>Add</strong>.</p>
<form action="" method="post">
<p><label for="text1">First Number:</label>
<input type="text" name="text1" />
</p>
<p><label for="text2">Second Number:</label>
<input type="text" name="text2" />
</p>
<p><input type="submit" value="Add" /></p>
</form>
<p>#totalMessage</p>
</body>
</html>
I think you are dealing with WebPages, Not MVC. The simplest way to develope webpages is to have WebMatrix.
Check out this tutorial to get started with WebMatrix
When it comes to your code, I only see one mistake i.e, #{ they should some side by side. Other than that everything is working good.
To run your cshtml in browser, please refer to the link I shared at top, that is clearly showing how to run the page in browser.
I think your immediate problem is that you cannot have a linebreak after the '#' character in razor. Try #{ then linebreak...