我正在尝试使用 C# 发送会议邀请,并且能够使用手动格式化的静态字符串获得我想要的内容 - 这是我能够使用静态字符串获得的内容的屏幕截图
public static void SendEmailString()
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("song@company.com", "Song");
msg.To.Add(new MailAddress("John@company.com", "John"));
msg.Subject = "CS Inquiry";
msg.Body = "TESTING";
string test = @"BEGIN:VCALENDAR
PRODID: -//Company & Com//Credit Inquiry//EN
VERSION:2.0
METHOD:REQUEST
BEGIN:VEVENT
ATTENDEE;CN=""John, Song"";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:song@company.com
ATTENDEE;CN=""Lay, Sean"";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:lins@company.com
ORGANIZER: John, Song
DTSTART:20171205T040000Z
DTEND:20171206T040000Z
LOCATION:New York
TRANSP:TRANSPARENT
SEQUENCE:0
UID:a16fbc2b-72fd-487f-adee-370dc349a2273asfdasd
DTSTAMP:20171027T215051Z
DESCRIPTION:Request for information regarding Test
SUMMARY:Summary
PRIORITY: 5
CLASS: PUBLIC
BEGIN:VALARM
TRIGGER:-PT1440M
ACTION: DISPLAY
DESCRIPTION:REMINDER
END:VALARM
END:VEVENT
END:VCALENDAR
";
SmtpClient …Run Code Online (Sandbox Code Playgroud) 我有一个字典列表,其键列表相同,但值不同。有没有办法使用 CSVHelper 将其写入 CSV 文件?我有下面的示例代码,但显然它不起作用。
static void Main(string[] args)
{
List<Dictionary<String, String>> records = new List<Dictionary<string, string>>();
Dictionary<String, String> data1 = new Dictionary<String, String>();
data1.Add("Name1", "Value1");
data1.Add("Name2", "Value2");
records.Add(data1);
Dictionary<String, String> data2 = new Dictionary<String, String>();
data2.Add("Name1", "Value1");
data2.Add("Name2", "Value2");
records.Add(data2);
using (var writer = new StreamWriter("e:\\temp\\test.csv"))
using (var csv = new CsvWriter(writer))
{
csv.WriteRecords(records);
//GEtting exception here
//CsvHelper.Configuration.CsvConfigurationException: 'Types that inherit IEnumerable cannot be auto mapped. Did you accidentally call GetRecord or WriteRecord which acts on a single record …Run Code Online (Sandbox Code Playgroud)