Body MailMessage C#

时间:2018-12-04 22:38:10

标签: c# mailmessage

我如何通过电子邮件正文传递列表?这就是我所拥有的,它返回vehicleNamesCount。我需要能够遍历Count并从列表中获取每个Name才能附加到电子邮件正文。我尝试将foreach添加到电子邮件的Body中,但是每次都会收到一个智能提示错误,因此,如果有可能,我做的不正确。感谢您的帮助。

 adminEmail.Body = "<div style='font-family: Arial, sans-serif default; font-size: 11pt;'><h2>Hello " + approverName + ",</h2>" +
                    "<p>A new key request has been received. Please log in to manage your request(s).</p></div>" +
                    "<div><hr align=\"left\" width=\"75%\"><br /><h3>Reservation Details</h3>" +
                    "<ul><li>Driver: " + employee.FirstName + " " + employee.LastName + "</li>" +
                    "<li>Driver Email: " + employee.HawkeyeEmail + "</li>" +
                    "<li>Destination: " + reservation.Destination + "</li>" +
                    "<li>Purpose of Trip: " + reservation.PurposeOfTrip + "</li>" +
                    "<li>Transporting Students: " + reservation.TransportStudentsFG.ToString() + "</li>" +
   help please! --> "<li>Vehicle(s): " + vehicleNames.ToString() + "</li></ul>" +  <-- help!
                    "<p><a href='" + reservationDetailsLink + "'>Click here to view and approve the request.</a></p><br /></div>";

1 个答案:

答案 0 :(得分:1)

您可以从此处使用String.Join(..,..)

https://docs.microsoft.com/en-us/dotnet/api/system.string.join?view=netframework-4.7.2#System_String_Join_System_String_System_String___

像这样:

string.Join(“,”,车辆名称)