summaryrefslogtreecommitdiffstats
path: root/SendGrid/SendGridMail/Transport/REST.cs
diff options
context:
space:
mode:
authorCJ Buchmann <cj.buchmann@sendgrid.com>2012-01-13 10:22:46 -0800
committerCJ Buchmann <cj.buchmann@sendgrid.com>2012-01-13 10:22:46 -0800
commit4f0b8b80306b3eab0d4250a6fb48cb2e57715395 (patch)
tree3724d56a64a43633716583c8b3478298ba22d0c0 /SendGrid/SendGridMail/Transport/REST.cs
parent13ea4240f2e863704320ae7c0dc62a6f59d592f0 (diff)
downloadsendgrid-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-xSendGrid/SendGridMail/Transport/REST.cs26
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.