MimeKit.MimeMessage.ToString C# (CSharp) 메소드

ToString() 공개 메소드

Returns a System.String that represents the current MimeKit.MimeMessage.

Returns a System.String that represents the current MimeKit.MimeMessage.

Note: In general, the string returned from this method SHOULD NOT be used for serializing the message to disk. It is recommended that you use WriteTo(Stream,CancellationToken) instead.

public ToString ( ) : string
리턴 string
		public override string ToString ()
		{
			using (var memory = new MemoryStream ()) {
				WriteTo (FormatOptions.Default, memory);

#if !PORTABLE && !COREFX
				var buffer = memory.GetBuffer ();
#else
				var buffer = memory.ToArray ();
#endif
				int count = (int) memory.Length;

				return CharsetUtils.Latin1.GetString (buffer, 0, count);
			}
		}

Usage Example

예제 #1
0
        private static void SendConfirmationEmail(GmailService gmail, Dictionary <string, string> dict)
        {
            MailMessage mailmsg = new MailMessage();

            {
                mailmsg.Subject = dict["subject"];
                mailmsg.Body    = string.Format(dict["HTML"], dict["link"]);
                mailmsg.From    = new MailAddress(dict["from"]);
                mailmsg.To.Add(new MailAddress(dict["to"]));
                mailmsg.IsBodyHtml = true;
            }
            ////add attachment if specified
            if (dict.ContainsKey("attachement"))
            {
                if (File.Exists(dict["attachment"]))
                {
                    Attachment data = new Attachment(dict["attachment"]);
                    mailmsg.Attachments.Add(data);
                }
                else
                {
                    Console.WriteLine("Error: Invalid Attachemnt");
                }
            }
            //Make mail message a Mime message
            MimeKit.MimeMessage mimemessage = MimeKit.MimeMessage.CreateFromMailMessage(mailmsg);
            Google.Apis.Gmail.v1.Data.Message finalmessage = new Google.Apis.Gmail.v1.Data.Message();
            finalmessage.Raw = Base64UrlEncode(mimemessage.ToString());
            var result = gmail.Users.Messages.Send(finalmessage, "me").Execute();
        }
All Usage Examples Of MimeKit.MimeMessage::ToString