Skip to content

Instantly share code, notes, and snippets.

@kunal732
Last active December 27, 2015 03:59
Show Gist options
  • Save kunal732/7264026 to your computer and use it in GitHub Desktop.
Save kunal732/7264026 to your computer and use it in GitHub Desktop.
send email with sendgrid-obj library
//create Email Object
sendgrid *msg = [sendgrid user:@"ApiUser" andPass:@"ApiKey"];
//set parameters
msg.subject = @"email subject";
msg.tolist = @[@"foo@bar.com", @"foo2@bar.com"];
msg.from = @"originalfoo@bar.com";
msg.text = @"hello world";
msg.html = @"<html><body><h1>hello world</h1></body></html>";
//adding unique arguments (Optional)
NSDictionary *uarg = @{@"customerAccountNumber":@"55555",
@"activationAttempt": @"1"};
[msg addCustomHeader:uarg withKey:@"unique_args"];
//adding categories (Optional)
NSString *replyto = @"billing_notifications";
[msg addCustomHeader:replyto withKey:@"category"];
//Image attachment (Optional)
[msg attachImage:self.photo];
//Send email through Web API Transport
[msg sendWithWeb];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment