I'm writing an asp.net mvc app. in c#, and I'm wondering if anybody can help me to understand, if it's possible to include an input from another field stored in the database, like a numeric or text string into a subject line of the email.
For example, along with the subject text, like "Your event registration" I'd like to add a "registartion ID" into a subject line of my email.
Right now i have a code in my emailhepler.cs:
public static void NotifyHtml(string toAddress, string subject, string body)
{
MailMessage message = new MailMessage();
message.To.Add(toAddress);
message.From = new MailAddress("coe-RoomReservations@coe.berkeley.edu");
message.Subject = subject;
Yes. When you call your method, you should be able to format your subject however you want. Eg,
NotifyHtml("coe-RoomReservations@coe.berkeley.edu", string.format("#{0} Your event registration", registrationId), body);
message.Subject = String.Format("{0} : {1}", subject, registrationID);
Yes. Hope I didn't misunderstand your question. MailMessage.Subject
is just a property of type String so you can include anything that's formatted as a string.
message.Subject = string.Format("Your event registration; registration id : {0}", registrationId);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.