diff options
-rwxr-xr-x | SendGrid/Example/Program.cs | 9 | ||||
-rwxr-xr-x | SendGrid/SendGridMail/SendGrid.cs | 59 |
2 files changed, 20 insertions, 48 deletions
diff --git a/SendGrid/Example/Program.cs b/SendGrid/Example/Program.cs index b14474c..fd52d13 100755 --- a/SendGrid/Example/Program.cs +++ b/SendGrid/Example/Program.cs @@ -14,14 +14,15 @@ namespace Example static void Main(string[] args)
{
var header = new Header();
- var transport = SMTP.GenerateInstance(new NetworkCredential("sgrid_username", "sgrid_password"));
+ var transport = SMTP.GenerateInstance(new NetworkCredential("cjbuchmann", "Gadget_15"));
var message = new SendGrid(header);
- message.AddTo("eric.becking@sendgrid.com");
- message.From = new MailAddress("eric@sendgrid.com");
+ message.AddTo("tyler.bischel@sendgrid.com");
+ message.From = new MailAddress("tbischel@gmail.com");
message.Text = "This is a test message.";
message.Html = "<html><p>This is a <b>test</b> message.</p></html>";
- message.Subject = "hazaah!";
+ message.Subject = "testing gravatar (in a sec)!";
+ message.EnableGravatar();
transport.Deliver(message);
}
}
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs index 5031c6f..04330d1 100755 --- a/SendGrid/SendGridMail/SendGrid.cs +++ b/SendGrid/SendGridMail/SendGrid.cs @@ -235,7 +235,12 @@ namespace SendGridMail }
}
- public Attachment[] Attachments { get; set; }
+ private List<Attachment> _attachments = new List<Attachment>();
+ public Attachment[] Attachments
+ {
+ get { return _attachments.ToArray(); }
+ set { _attachments = value.ToList(); }
+ }
public void AddSubVal(String tag, params String[] value)
{
@@ -246,55 +251,18 @@ namespace SendGridMail public void AddAttachment(String filePath)
{
var data = new Attachment(filePath, MediaTypeNames.Application.Octet);
-
- if (Attachments == null)
- {
- Attachments = new Attachment[1];
- Attachments[0] = data;
- }
- else
- {
- var i = Attachments.Count();
- var tmp = new Attachment[i + 1];
- Attachments.CopyTo(tmp, 0);
- Attachments = tmp;
- Attachments[i] = data;
- }
+ _attachments.Add(data);
}
public void AddAttachment(Attachment attachment)
{
- if (Attachments == null)
- {
- Attachments = new Attachment[1];
- Attachments[0] = attachment;
- }
- else
- {
- var i = Attachments.Count();
- var tmp = new Attachment[i + 1];
- Attachments.CopyTo(tmp, 0);
- Attachments = tmp;
- Attachments[i] = attachment;
- }
+ _attachments.Add(attachment);
}
public void AddAttachment(Stream attachment, ContentType type)
{
- var data = new Attachment(attachment, type);
- if (Attachments == null)
- {
- Attachments = new Attachment[1];
- Attachments[0] = data;
- }
- else
- {
- var i = Attachments.Count();
- var tmp = new Attachment[i + 1];
- Attachments.CopyTo(tmp, 0);
- Attachments = tmp;
- Attachments[i] = data;
- }
+ var data = new Attachment(attachment, type);
+ _attachments.Add(data);
}
public IEnumerable<String> GetRecipients()
@@ -471,7 +439,7 @@ namespace SendGridMail String smtpapi = Header.AsJson();
if (!String.IsNullOrEmpty(smtpapi))
- message.Headers.Add("X-SmtpApi", "{" + smtpapi + "}");
+ message.Headers.Add("X-SmtpApi", smtpapi);
if(Attachments != null)
{
@@ -500,7 +468,10 @@ namespace SendGridMail public void Mail()
{
- throw new NotImplementedException();
+ SmtpClient client = new SmtpClient("localhost");
+ client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
+ client.PickupDirectoryLocation = @"C:\temp";
+ client.Send(message);
}
}
}
|