diff options
author | Brandon West <brawest@gmail.com> | 2013-01-14 10:27:09 -0700 |
---|---|---|
committer | Brandon West <brawest@gmail.com> | 2013-01-14 10:27:09 -0700 |
commit | 41f4b13ffd8196113e005314627fba74a148c8da (patch) | |
tree | cd22035ce9c6facf56fe6e2d2cd527471898b891 /SendGrid/Example/WEBAPI.cs | |
parent | 5b42e76f7e70890e20413e5d2861773d11ce882f (diff) | |
download | sendgrid-csharp-41f4b13ffd8196113e005314627fba74a148c8da.zip sendgrid-csharp-41f4b13ffd8196113e005314627fba74a148c8da.tar.gz sendgrid-csharp-41f4b13ffd8196113e005314627fba74a148c8da.tar.bz2 |
attaching files works
Diffstat (limited to 'SendGrid/Example/WEBAPI.cs')
-rwxr-xr-x | SendGrid/Example/WEBAPI.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/SendGrid/Example/WEBAPI.cs b/SendGrid/Example/WEBAPI.cs index 985005d..d52786d 100755 --- a/SendGrid/Example/WEBAPI.cs +++ b/SendGrid/Example/WEBAPI.cs @@ -5,6 +5,7 @@ using System.Net; using System.Net.Mail;
using SendGridMail;
using SendGridMail.Transport;
+using System.IO;
namespace Example
{
@@ -46,6 +47,19 @@ namespace Example //set the message subject
message.Subject = "Hello World HTML Test";
+ //add a file from stream
+ var file = "bar";
+
+ var memoryStream = new MemoryStream();
+ var stream = new StreamWriter(memoryStream);
+ stream.Write(file);
+ message.AddAttachment(memoryStream, "foo.txt");
+ stream.Flush();
+ stream.Close();
+
+ //add a file from disk
+ message.AddAttachment("test.txt");
+
//create an instance of the Web transport mechanism
var transportInstance = Web.GetInstance(new NetworkCredential(_username, _password));
|