Last post Dec 19, 2017 08:08 AM by PatriceSc
Dec 16, 2017 06:53 AMemail@example.com|LINK
My website have contact form where customer fill their details for that I use domain email to send filled details to my inbox. Form working good but the issue is when details come to my inbox its look like: Name - 5a313471b73da, mobile No.'blank' etc.
And one more thing it is working for my country, all details come to my inbox as it but when submit from other country then this issue is coming...
here is my code...
//Gmail Address from where you send the mail
var fromAddress = System.Configuration.ConfigurationManager.AppSettings["FromEmailId"].ToString();
// any address where the email will be sending
var toAddress = "email";
//Password of your gmail address
string fromPassword = System.Configuration.ConfigurationManager.AppSettings["FromPwd"].ToString();
// Passing the values and make a email formate to display
string subject = "Enquiry";
// smtp settings
MailMessage Msg = new MailMessage();
MailAddress fromMail = new MailAddress(fromAddress);
// Sender e-mail address.
Msg.From = fromMail;
// Recipient e-mail address.
// Subject of e-mail
Msg.Subject = "Enquiry";
string body = "Name - " + name.Text.ToString() + "\n";
body += "Email Id -" + emailId.Text.ToString() + "\n";
body += "Contact No -" + Phone.Text.ToString() + "\n";
body += "Subject -" + Subject.Text.ToString() + "\n";
body += "Message -" + message.Text.ToString() + "\n";
Msg.IsBodyHtml = true;
var smtp = new System.Net.Mail.SmtpClient();
smtp.Host = "smtpout.secureserver.net";
smtp.Port = 3535;
smtp.EnableSsl = false;
// smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
smtp.Timeout = 200000;
smtp.Send(fromAddress, toAddress, subject, body);
Dec 16, 2017 08:30 AM|PatriceSc|LINK
I don't see anything related to the country in your code. So I can't imagine why you see a difference depending on which country is selected (not 100% sure which differences).
Also it is confusing that you create a MailMessage while finally not using it for the final "Send". Do you have changed something to try fixing your issue? For example if you try to send an HTML message body, multiple spaces are collapsed to a single space
and newline is ignored (which is for now my understanding about what you see).
Start first by making sure if you want to use HTML or plain text messages. Also see maybe
https://docs.microsoft.com/en-us/visualstudio/debugger/ to inspect how your app runs and possibly spot the issue.
This is really the entire code? For now it seems to me you are sending sometimes an HTML message and sometimes a plain text message ???
Dec 16, 2017 09:08 AMfirstname.lastname@example.org|LINK
Thanks for your suggestion.
There is no selection of country just i want to say when website open in other country and submit contact form.
Dec 19, 2017 02:09 AM|Fei Han - MSFT|LINK
"Name - "
"Email Id -"
"Contact No -"
According to your code, you retrieve the values of TextBoxes (name, emailId and Phone etc) and set the message body with these input values. If the format of these input values are not always as your expected, please check if you do validation to check user
inputs. If you do not check the information that user enters are valid before submit the form, the email receiver might receive non meaningful data, like
Name - 5a313471b73da. To avoid it, you can do client validation to check user inputs before user submit the form.
Name - 5a313471b73da
Dec 19, 2017 04:22 AMemail@example.com|LINK
hi Fie Han,
Yes, I have use client side validation for email and Phone but not working.
Its working for India but when client open web site in other country then this problem come.
Dec 19, 2017 08:08 AM|PatriceSc|LINK
So your web site uses the browser preferred language ? I'm trying to understand the EXACT issue and how it could be related to the "current" country (and you always have the problem for other countries or it happens just sometimes ?)
First as your code uses both a MailMessage object but finally sends directly the text without using the MailMessage it is unclear if you want to send an HTML or a plain text message. Which format do you want ?
For now my understanding is that newlines are not showing up in the mail (which is expected for HTML which uses <br> rather than newline).