Reputation: 21
I want to send shopping cart item list that user purchased from website to registered user. How to send product list that user purchased with user's information in mvc?
I used for
loop in mvc controller to display purchase order list and tried to save it in email body but it gives me error. Please suggest me how to save whole data into email body.
Following is the code snippet I have used for mailing purpose.
MailMessage mail = new MailMessage();
mail.To.Add("receiver");
mail.From = new MailAddress("[email protected]");
mail.Subject = "OnlineBartan:Thanks For Order";
string Body = "s" + orderproduct[1].OrderId +"sdfs";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtpout.asia.secureserver.net";
smtp.Port = 25;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential
("[email protected]", "Mukesh@1980");
smtp.EnableSsl = false;
smtp.Send(mail);
Upvotes: 2
Views: 720
Reputation: 41
You have not specified exact error you are getting but I can immediately see is you should set valid html string to mail.Body property when you're setting mail.IsBodyHtml = true. Hope this helps.
Upvotes: 0
Reputation: 14624
You can loop through list and append in string
string Body="";
for(int i=0;i<orderproduct.Count;i++)
Body += "s" + orderproduct[i].OrderId +"sdfs <br />";
Upvotes: 1