Shubham Singh
Shubham Singh

Reputation: 9

How to set dynamic Subject body in email message body?

Hey i am trying to send mail, and here is code in c#

 objEmail.Subject = string.Format("Questionnaire={0}",Request.QueryString["orgname"]);

but +Request.QueryString["orgname"]"; not working

and its exact link

Questionnaire Test org

"Test org" is Dynamic according to user

Upvotes: 1

Views: 535

Answers (1)

Soner Gönül
Soner Gönül

Reputation: 98750

Your string concatenation is wrong. You attemp to add your Request.QueryString["ID"] as a part of string, not a variable. You can use;

string MsgBody = "https://example.com/Coordinator/Questionnaire.aspx?OnsiteRequest=" + Request.QueryString["ID"];

or you can string.Format like;

string MsgBody = string.Format("https://example.com/Coordinator/Questionnaire.aspx?OnsiteRequest={0}", 
                                Request.QueryString["ID"]);

Upvotes: 1

Related Questions