string strTheBody = #"First Name: " + tbFirst.Text + "\nLast Name: " + tbLast.Text + "\nAddress 1: " + tbAdd1.Text + "\nAddress 2: " + tbAdd2.Text + "";
strTheBody += #"\nCity: " + tbCity.Text + "\nState: " + ddlTechState.SelectedValue + "\nZip Code: " + tbZip.Text + "\nDOB: " + tbDOB.Text + "\nEmail Address: " + tbEmail.Text + "";
strTheBody += #"\nLast Doctor visited: " + ddlTechProvider.SelectedValue + "\nIssue: " + ddlTechIssues.SelectedValue + "\n\nComments: " + HttpUtility.HtmlEncode(tbComments.Text) + "";
MailMessage mmSendEmail = new MailMessage();
mmSendEmail.To.Add("myemail#myweb.com");
mmSendEmail.From = new MailAddress(tbEmail.Text);
mmSendEmail.Subject = "Contacting about " + ddlTechIssues.SelectedValue;
mmSendEmail.Body = strTheBody;
SmtpClient scSend = new SmtpClient("mysmtp.myisp.com");
scSend.Send(mmSendEmail);
Sends the email like this:
First Name: first
Last Name: last
Address 1: my address 1
Address 2: \nCity: some city
State: NV
Zip Code: 90320
DOB: 08/08/2013
Email Address: myemail#email.com\nLast Doctor visited: 0
Issue: Result
Comments: This is a comment
How can I resolve the issue with the \n being displayed if the value is empty and when there is an email address.
# symbol means to read that string literally, and don't interpret
control characters
https://stackoverflow.com/a/3312007/3087342
I suggest using StringBuilder instead, will remove these type of errors and makes your code generally a lot more readable - in terms of formatting the email anyway.
Related
While sent email using below subject which apostrophe replacing with another characters
Actual Subject : We’ll make 100,800 cold calls for you
Mail Shows Subject : We’ll make 100,800 cold calls for you
Issue happens when I'm sent email via api , when sent email from SMTP it's working fine
Please check my api code below
string msg = "From: " + FromName + "<" + From + ">" + " \r\n" +
"To: " + ToName + "<" + To + ">" + " \r\n" +
"BCC: " + BCCEmail + " \r\n" +
"Subject: " + Subject + " \r\n" +
"Message-ID: mID_" + messageID + "\r\n" +
"References: "+encryptMessageID + "\r\n" +
"In-Reply-To: " + encryptMessageID + "\r\n" +
"Content-Type: " + contentType + "; charset=us-ascii\r\n\r\n" + Body;
dynamic objSendMsg = new { raw = commonFunction.Base64UrlEncode(msg) };
if (!string.IsNullOrEmpty(messageThreadID))
objSendMsg = new { raw = commonFunction.Base64UrlEncode(msg), threadId = messageThreadID };
var _objSendMsg = JsonConvert.SerializeObject(objSendMsg);
var strSendMsg = new StringContent(_objSendMsg, UnicodeEncoding.UTF8, "application/json");
When same content i'm applying in body with apostrophe working fine for body
Please check attached screenshot
Email copy
You need to base64_encode of the subject header your sending it as plain text. the API is getting confused.
Subject: " + Convert.ToBase64String(Subject) + " \r\n" +
Starting with an example, I have some keywords like
Narendra Modi, Modi, India, Speech, Parliament
And I have a story with text
Narendra Modi will give a speech in the parliament of India.
Now I want my regex to replace the keyword with the hyperlink in the story.
<a>Narendra Modi</a> will give speech in the <a>parliament</a> of <a>India.</a>
My Code for this is
var tagArray = bodykeywords.Split(',').ToList();
foreach (var tag in tagArray.OrderBy(a => a.Length))
{
var replaceTag = tag.Replace("(", "");
replaceTag = replaceTag.Replace(")", "");
DataDesc = Regex.Replace(DataDesc, "\"" + replaceTag.Trim() + "\"", " \"" + replaceTag.Trim() + "\" ");
DataDesc = Regex.Replace(DataDesc, " " + replaceTag.Trim() + ", ", " " + replaceTag.Trim() + ", ");
DataDesc = Regex.Replace(DataDesc, " " + replaceTag.Trim() + " ", " " + replaceTag.Trim() + " ");
}
Problem is I am not able to replace the word with full stop like India in the given example and Word with repetition like Narendra Modi, Modi in the keyword.
Is there a way to add a pause (preferably 1 second) in Amazon Alexa without using SSML? Perhaps there is a trick I can do with the Outputspeech.Text and I just don't know it.
Below, I am saying "Here are works of art by {artist name}" but the name and the start of the works of art become mixed together - in spite of the period - so I end up with things like "Here are the works of art by Pablo Picasso Harlequin..."
I am using C# and my own https endpoint, not AWS Lambda.
Any suggestions? Otherwise I will add it as SSML. Thanks.
var output = new StringBuilder();
var outputCard = new StringBuilder();
string m_location;
string m_current_location;
string m_artist = dt_artist.Rows[0]["DisplayName"].ToString();
output.Append("here are works of art for " + m_artist + ". ");
outputCard.Append("Here are works of art for " + m_artist + ".\n\n");
foreach (DataRow dr in dt_artist_objs.Rows)
{
m_current_location = dr["CurrentLocation"].ToString();
if (m_current_location == " ")
{
m_location = "The location is not available.";
}
else
{
m_location = "It is located on the " + m_current_location;
}
output.Append(dr["Title"].ToString() + " is a " + dr["Classification"].ToString() + ". The medium is " + dr["Medium"].ToString() + ". " + m_location);
outputCard.Append(dr["Title"].ToString() + ", " + dr["Dated"].ToString() + " is a " + dr["Classification"].ToString() + ". The medium is " + dr["Medium"].ToString() + ". " + dr["Creditline"].ToString() + ". " + m_location + ".\n"); // It is located on the " + dr["CurrentLocation"].ToString());
}
sql_conn_data.Close();
response.Response.OutputSpeech.Text = output.ToString();
response.Response.Card.Title = "Art";
response.Response.Card.Type = "Standard";
response.Response.Card.Text = outputCard.ToString();
response.Response.ShouldEndSession = true;
return response;
UPDATE
OK. Ended up going the SSML route which looks like this:
var output = new StringBuilder();
var outputCard = new StringBuilder();
string m_location;
string m_current_location;
string m_location_card;
string m_artist = dt_artist.Rows[0]["DisplayName"].ToString();
output.Append("<speak>");
output.Append("here are works of art for " + m_artist + ". <break time='1s'/> ");
outputCard.Append("Here are works of art for " + m_artist + ".\n\n");
foreach (DataRow dr in dt_artist_objs.Rows)
{
m_current_location = dr["CurrentLocation"].ToString();
if (m_current_location == " ")
{
m_location = "The location is not available. <break time='1s' />";
m_location_card = "The location is not available. ";
}
else
{
m_location = "It is located on the " + m_current_location + "<break time = '1s' />";
m_location_card = "It is located on the " + m_current_location;
}
output.Append(dr["Title"].ToString() + " is a " + dr["Classification"].ToString() + ". The medium is " + dr["Medium"].ToString() + ". " + m_location);
outputCard.Append(dr["Title"].ToString() + ", " + dr["Dated"].ToString() + " is a " + dr["Classification"].ToString() + ". The medium is " + dr["Medium"].ToString() + ". " + dr["Creditline"].ToString() + ". " + m_location_card + ". \n");
}
output.Append("</speak>");
sql_conn_data.Close();
response.Response.OutputSpeech.Ssml = output.ToString();
response.Response.OutputSpeech.Type = "SSML";
response.Response.Card.Title = "Art";
response.Response.Card.Type = "Standard";
response.Response.Card.Text = outputCard.ToString();
response.Response.ShouldEndSession = true;
return response;
}
There is not a way to introduce a pause in Alexa without SSML. You will need to build the ssml string and return it back to Alexa using the pause, or the cadence strings.
I have the following code segment that sends an email to users based on 'RequestApproval' being set to true on their records in a SQL table - it works perfectly.
SmtpClient mySmtpClient = new SmtpClient();
List<SigList> LST_SigList = LK_CRFData.SigLists.Where(x => x.RequestApproval == true).ToList();
string URL = sponsorURL + OB_CRF.id;
foreach (SigList OB_SigList in LST_SigList)
{
string Name = OB_SigList.UserName.Trim();
Name = Name.Substring(0, Name.IndexOf("."));
Name = Name[0].ToString().ToUpper() + Name.Substring(1, Name.Length - 1);
MailMessage myMessage = new MailMessage("SponsorApproved#nhs.net", OB_SigList.EmailAddress);
myMessage.Subject = "Sponsor has approved the request on the " + TB_DateTimeofImplementationStart.Text.Substring(0, 10) + " for \"" + TB_CNNO.Text + " " + TB_Title.Text + "\"";
myMessage.Body = "Dear " + Name + ", \n\nThe sponsor has now approved CN NO : " + TB_CNNO.Text + "\nTitle : " + TB_Title.Text + "\nImplementation Date : " + TB_DateTimeofImplementationStart.Text.Substring(0, 10) + "\n\nClick the link to open the document:\n" + URL;
mySmtpClient.Send(myMessage);
}
However, for certain functions, I want to send the email where 'Request approval is set to True OR False. I've ammended it to the following to no avail:
List<SigList> LST_SigList = LK_CRFData.SigLists.Where(x => x.RequestApproval == true || x.RequestApproval == false).ToList();
It still sends emails out the old way -only to those who have Request Approval' set to true.
Any ideas?
Thanks
I am trying to send a email from my webform1 once a new work order has been created, however when the user clicks the workorder number i want that workorder number to be passed as a parameter to webform2. the code i use to send the email:
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage();
mm.From = new System.Net.Mail.MailAddress("some#some.com");//who send
mm.To.Add(new System.Net.Mail.MailAddress("some#gmail.com"));
mm.To.Add(new System.Net.Mail.MailAddress("some#some.com"));
mm.Subject = "WorkOrders Created With Type Safety";
mm.Body = "WorkOrderNumber" + ": "
+ "<a href=\"http://localhost:49695/Safety.aspx?=WorkOrderNum=\">"
+ TextBox13.Text + "</a>"
+ "<-Click on the Work Order Number" + "<br><br/>"
+ "Requestor" + ": " + TextBoxRequestor.Text
+ "<br><br/>" + "Date" + ": " + TextBoxDate.Text
+ "<br><br/>" + "Department" + ": " + TextBoxDepartment.Text
+ "<br><br/>" + "Completion Date" + ": "
+ TextBoxCompletionDate.Text + "<br><br/>" + "Machine Description"
+ ": " + TextBoxMachineDescription.Text + "<br><br/>"
+ "Machine Location" + ": " + TextBoxMachineLocation.Text
+ "<br><br/>" + "Work Required" + ": " + TextBoxWorkRequired.Text
+ "<br><br/>" + "Status" + ": " + TextBoxStatus.Text;
mm.IsBodyHtml = true;
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
client.Host = ConfigurationManager.AppSettings["smtpServer"];
client.Send(mm);
when the above code is sent as an email the result looks like this and the 14 is clickable link:
WorkOrderNumber: 14<-Click on the Work Order Number
Requestor: Mark
Date: 01/07/2015
Department: IT
Completion Date: 01/08/2015
Machine Description: Fan
Machine Location: SomeLocation
Work Required: Needs Installing
Status: Open
so then on webform2 i would be able to use this:
protected void Page_Load(object sender, EventArgs e)
{
var workourdernum = Request.QueryString["WorkOrderNum"];
}
so i just want that number from TextBox13.Text be passed along with the link, i looked online people are accomplishing similar task via Response.Redirect()
Will this work?
"<a href=\"http://localhost:49695/Safety.aspx?WorkOrderNum=" +
+ TextBox13.Text + "\">" + TextBox13.Text + "</a>"
+ "<-Click on the Work Order Number" + "<br><br/>"
You'd be passing the work order number in the query string. Your web page could then just extract the work order number from the query string.
You'll get HTML that looks like this:
123
The code you already have (for Page_Load) would work perfectly to extract the work order number in the second page.
Here is example how to pass value from one form to another.
webform1.aspx - for example on button click event
Response.Redirect("webform2.aspx?number=" + TextBox13.Text);
webform2.aspx
int passedNumber;
protected void Page_Load(object sender, EventArgs e)
{
if (Request["number"] != null)
{
passedNumber = Convert.ToInt32(Request["number"]);
}
}
Now you can do what ever you want with that number on webform2.