diff options
author | CJ Buchmann <cj.buchmann@sendgrid.com> | 2012-01-13 10:22:46 -0800 |
---|---|---|
committer | CJ Buchmann <cj.buchmann@sendgrid.com> | 2012-01-13 10:22:46 -0800 |
commit | 4f0b8b80306b3eab0d4250a6fb48cb2e57715395 (patch) | |
tree | 3724d56a64a43633716583c8b3478298ba22d0c0 /SendGrid/SendGridMail/Transport/REST.cs | |
parent | 13ea4240f2e863704320ae7c0dc62a6f59d592f0 (diff) | |
download | sendgrid-csharp-4f0b8b80306b3eab0d4250a6fb48cb2e57715395.zip sendgrid-csharp-4f0b8b80306b3eab0d4250a6fb48cb2e57715395.tar.gz sendgrid-csharp-4f0b8b80306b3eab0d4250a6fb48cb2e57715395.tar.bz2 |
Attempting to attach files via REST
Diffstat (limited to 'SendGrid/SendGridMail/Transport/REST.cs')
-rwxr-xr-x | SendGrid/SendGridMail/Transport/REST.cs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/SendGrid/SendGridMail/Transport/REST.cs b/SendGrid/SendGridMail/Transport/REST.cs index 3a77c3f..13abfed 100755 --- a/SendGrid/SendGridMail/Transport/REST.cs +++ b/SendGrid/SendGridMail/Transport/REST.cs @@ -23,6 +23,8 @@ namespace SendGridMail.Transport private readonly String _restEndpoint;
private readonly String _format;
+ private WebFileUpload _fileUpload;
+
public REST(NetworkCredential credentials, String url = Endpoint)
{
_query = new List<KeyValuePair<string, string>>();
@@ -70,10 +72,32 @@ namespace SendGridMail.Transport var restCommand = new Uri(_restEndpoint + "?" + queryString);
+ var request = (HttpWebRequest)WebRequest.Create(restCommand.AbsoluteUri);
+
+ Console.WriteLine(restCommand.AbsoluteUri);
+
+ //if we have message attachments, we'll send them via the WebFileUpload
+ if(message.Attachments.Length > 0)
+ {
+ Console.WriteLine("Initializing the File Upload Library");
+
+ //Console.WriteLine("file is "+message.Attachments.First());
+ //Console.WriteLine("DONE");
+
+ /*var collection = new NameValueCollection();
+ collection.Add("api_user", "cjbuchmann");
+ collection.Add("api_key", "Gadget_15");
+ collection.Add("from", "cj.buchmann@sendgrid.com");
+ collection.Add("to", "cj.buchmann@sendgrid.com");
+ collection.Add("subject", "hello world test");
+ collection.Add("text", "hello world plain text");*/
+ new WebFileUpload(request).testNoAttach(message.Attachments.First());
+ //string outdata = WebFileUpload.UploadFileEx(@"D:\att_proj\21.jpg", "https://sendgrid.com/api/mail.send.xml", "files[file1.jpg]", "", collection);
+ }
+
Console.WriteLine(restCommand.AbsoluteUri);
Console.WriteLine("DONE!");
- var request = (HttpWebRequest)WebRequest.Create(restCommand.AbsoluteUri);
var response = (HttpWebResponse)request.GetResponse();
// Basically, read the entire message out before we parse the XML.
|