Hello,
I have created a webform (ASP.NET C#) named "SendEmails.aspx".
This webform has RadGrid named 'RadGrid1' and a button inside the Record Edit-Template area of RadGrid1 which, when clicked, sends out an email message to the email address typed in to the text box named 'txtEmail' which is also inside the template area of RadGrid1.
The email message's body text comes from the message typed in to the Telerik RAD editor named 'RadEditor1' placed inside the Edit-Template area of RadGrid1.
The email message's subject comes from the text typed into the text box named 'txtEmailSubject' which is also placed on the Edit-Template area of RadGrid1.
The code I'm using to send out the email when the button is clicked is shown below.
When the button is clicked, the email message is sent out OK.
But, the strange thing is, the email message's subject line always shows the subject text that I have been using 3 days ago ("Confirmation Letter") and it doesn't show/use the text typed in to the 'txtEmailSubject' by the user where this email message should get it's subject line from. No matter whatever text I typed into the 'txtEmailSubject' text box, the email message always uses the text "Confirmation letter" as the subject of the email message. Even if I hard type the subject as "New email message subject" into the code shown above, the change isn't reflected.
Moreover, again, strangely, the email message's SENDER isn't admin@mydomainname.com that I have typed in to the code shown above, but the email message shows the sender is info@mydomainname.com that I have been using 3 days ago.How can this happen?Is this caused by ASP.NET or IIS caching? I have tried changing the SMTP server, deleting all caches for IE, Firefox, Chrome but didn't solve the problem at all.
But. the email message's body text shows the correct message typed into the Telerik Rad editor.
Please explain how to solve this problem.
Thank you.
I have created a webform (ASP.NET C#) named "SendEmails.aspx".
This webform has RadGrid named 'RadGrid1' and a button inside the Record Edit-Template area of RadGrid1 which, when clicked, sends out an email message to the email address typed in to the text box named 'txtEmail' which is also inside the template area of RadGrid1.
The email message's body text comes from the message typed in to the Telerik RAD editor named 'RadEditor1' placed inside the Edit-Template area of RadGrid1.
The email message's subject comes from the text typed into the text box named 'txtEmailSubject' which is also placed on the Edit-Template area of RadGrid1.
The code I'm using to send out the email when the button is clicked is shown below.
protected
void
Send_Confirmation_Email(
object
sender, EventArgs e)
{
MailMessage myMessage =
new
MailMessage();
//The 4 lines of code shown below is for receiving the content stored in the RADEditor control 'RadEditor1'.
//and stores in the string variable named 'content'.
Button GetContent = (Button)sender;
GridEditFormItem item = (GridEditFormItem)GetContent.NamingContainer;
RadEditor radEditor = ((RadEditor)item.FindControl(
"RadEditor1"
));
string
content = radEditor.Content;
TextBox txtEmail = item.FindControl(
"txtEmail"
)
as
TextBox;
TextBox txtFirstname = item.FindControl(
"txtFirstname"
)
as
TextBox;
TextBox txtSurname = item.FindControl(
"txtSurname"
)
as
TextBox;
TextBox txtEmailSubject = item.FindControl(
"txtEmailSubject"
)
as
TextBox;
string
EmailAddress = txtEmail.Text;
string
ToName = txtFirstname.Text +
" "
+ txtSurname.Text;
string
EmailSubject = txtEmailSubject.Text;
myMessage.Body = content;
myMessage.From =
new
MailAddress(
"admin@mydomainname.com"
,
"Support"
);
myMessage.To.Add(
new
MailAddress(EmailAddress, ToName));
myMessage.Subject = EmailSubject;
//myMessage.Subject = "New email message subject";
SmtpClient mySmtpClient =
new
SmtpClient();
myMessage.IsBodyHtml =
true
;
mySmtpClient.UseDefaultCredentials =
true
;
mySmtpClient.Send(myMessage);
}
When the button is clicked, the email message is sent out OK.
But, the strange thing is, the email message's subject line always shows the subject text that I have been using 3 days ago ("Confirmation Letter") and it doesn't show/use the text typed in to the 'txtEmailSubject' by the user where this email message should get it's subject line from. No matter whatever text I typed into the 'txtEmailSubject' text box, the email message always uses the text "Confirmation letter" as the subject of the email message. Even if I hard type the subject as "New email message subject" into the code shown above, the change isn't reflected.
Moreover, again, strangely, the email message's SENDER isn't admin@mydomainname.com that I have typed in to the code shown above, but the email message shows the sender is info@mydomainname.com that I have been using 3 days ago.How can this happen?Is this caused by ASP.NET or IIS caching? I have tried changing the SMTP server, deleting all caches for IE, Firefox, Chrome but didn't solve the problem at all.
But. the email message's body text shows the correct message typed into the Telerik Rad editor.
Please explain how to solve this problem.
Thank you.