mirror of https://github.com/smiley22/S22.Mail.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
![]() |
13 years ago | |
---|---|---|
Properties | 13 years ago | |
SerializableMailMessage | 13 years ago | |
.gitattributes | 13 years ago | |
.gitignore | 13 years ago | |
Bodypart.cs | 13 years ago | |
ContentDisposition.cs | 13 years ago | |
ContentTransferEncoding.cs | 13 years ago | |
ContentType.cs | 13 years ago | |
Extensions.cs | 13 years ago | |
License.md | 13 years ago | |
MIMEPart.cs | 13 years ago | |
MailMessage.cs | 13 years ago | |
MessageBuilder.cs | 13 years ago | |
Readme.md | 13 years ago | |
S22.Mail.csproj | 13 years ago | |
S22.Mail.sln | 13 years ago | |
Util.cs | 13 years ago |
Readme.md
Introduction
This repository contains a .NET assembly which adds a couple of extension methods to the MailMessage class of the System.Net.Mail namespace. It also contains a serializable replica of the MailMessage class.
Usage & Examples
To use the library add the S22.Mail.dll assembly to your project references in Visual Studio. The SerializableMailMessage class implements conversion operators to allow for implicit conversion between SerializableMailMessage and MailMessage objects.
using System;
using System.IO;
using System.Net.Mail;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using S22.Mail;
namespace Test {
class Program {
static void Main() {
MailMessage msg = MyMailMessage();
IFormatter formatter = new BinaryFormatter();
using(MemoryStream s = new MemoryStream()) {
// Serialize MailMessage to memory stream
formatter.Serialize(s, (SerializableMailMessage)message);
// Rewind stream and deserialize MailMessage
s.Seek(0, SeekOrigin.Begin);
MailMessage Tmp = (SerializableMailMessage)formatter.Deserialize(s)
Console.WriteLine(Tmp.Subject);
Console.WriteLine(Tmp.Body);
}
}
static MailMessage MyMailMessage() {
MailMessage m = new MailMessage("John@Doe.com", "Jane@Doe.com");
m.Subject = "Hello World";
m.Body = "This is just a test";
m.Attachments.Add(new Attachment("Test.cs""));
return m;
}
}
}
Extension Methods
System.Net.Mail.MailMessage
- Load(Stream stream)
- Load(string name)
- Save(Stream stream)
- Save(string name)
System.Net.Mail.Attachment
- SaveAs(string name)
Credits
This library is copyright © 2012 Torben Könke.
License
This library is released under the MIT license.
Bug reports
Please send your bug reports and questions to smileytwentytwo@gmail.com or create a new issue on the GitHub project homepage.