Example #1
0
 private static void SaveToEml(MailMessage msg, string emlFileAbsolutePath)
 {
     using (MemoryStream stream = new MemoryStream())
     {
         object obj2 = Activator.CreateInstance(typeof(SmtpClient).Assembly.GetType("System.Net.Mail.MailWriter"), BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { stream }, CultureInfo.InvariantCulture);
         msg.GetType().GetMethod("Send", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Instance).Invoke(msg, new object[] { obj2, true });
         File.WriteAllText(emlFileAbsolutePath, Encoding.Default.GetString(stream.ToArray()), Encoding.UTF8);
     }
 }