0

我正在创建一个看起来像这样的偶数附件。

    string schLocation = "Conference Room";
    string schSubject = "Business visit discussion";
    string schDescription = "Schedule description";
    System.DateTime schBeginDate = Convert.ToDateTime("7/3/2008 10:00:00 PM");
    System.DateTime schEndDate = Convert.ToDateTime("7/3/2008 11:00:00 PM");

    //PUTTING THE MEETING DETAILS INTO AN ARRAY OF STRING

    String[] contents = { "BEGIN:VCALENDAR",
                          "PRODID:-//Flo Inc.//FloSoft//EN",
                          "BEGIN:VEVENT",
                          "DTSTART:" + schBeginDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
                          "DTEND:" + schEndDate.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"),
                          "LOCATION:" + schLocation,
                     "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + schDescription,
                          "SUMMARY:" + schSubject, "PRIORITY:3",
                     "END:VEVENT", "END:VCALENDAR" };

    /*THE METHOD 'WriteAllLines' CREATES A FILE IN THE SPECIFIED PATH WITH 
   THE SPECIFIED NAME,WRITES THE ARRAY OF CONTENTS INTO THE FILE AND CLOSES THE
    FILE.SUPPOSE THE FILE ALREADY EXISTS IN THE SPECIFIED LOCATION,THE CONTENTS 
   IN THE FILE ARE OVERWRITTEN*/

    System.IO.File.WriteAllLines(Server.MapPath("Sample.ics"), contents);

    //METHOD TO SEND EMAIL IS CALLED
    //  SendMail();
    //System.Net.Mail.Attachment mailAttachment = new Attachment(Server.MapPath("Sample.ics"));

}

现在我想通过电子邮件发送附件,而不是使用 smtp,而是使用 API 方法,例如HttpBasicAuthenticator我如何在 smtp 中以这种方法发送附件,它Attachment是 API 中使用的库?

4

1 回答 1

0

通过您使用的 API 发送电子邮件时,我找到了答案

 RestClient client = new RestClient();

然后用这行代码有附件

request.AddFile("attachment", path);

它看起来像这样

这是您可以下载您发送的附件的方式

源链接文档

于 2017-10-04T16:16:38.390 回答