0

I am using iOS with parse.com and mailgun. I am trying to send an email with a pdf attached. I have read that the parse.com cloudCode doesn't allow attachments. But I have also seen this post, Mailgun: Sending image using parse cloud code ,saying instead of attaching place it inline.

First off, is this still the case, that we cannot send attachments via cloud code? If so, could someone give me a hand in figuring out how to get a pdf from my app into an email sent through mail gun? Im not using the built in mail view from apple because I need to be able to set the "from" address of the email.

I have the pdf created dynamically in the app and I present it in the code like this:

NSString* fileName = @"Invoice.PDF";

NSArray *arrayPaths =
NSSearchPathForDirectoriesInDomains(
                                    NSDocumentDirectory,
                                    NSUserDomainMask,
                                    YES);
NSString *path = [arrayPaths objectAtIndex:0];
NSString* pdfFileName = [path stringByAppendingPathComponent:fileName];

UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 60, 320, 480)];

NSURL *url = [NSURL fileURLWithPath:pdfFileName];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView setScalesPageToFit:YES];
[webView loadRequest:request];

[self.view addSubview:webView];

I don't know how to get the file from the Docdir into the proper data form and either attached (if now possible) or place it inline like the post mentions above.

Any help would be appreciated. If you need more info, have questions or have alternate idea on how to accomplish this task please ask/suggest.

Thanks in advance

Community
  • 1
  • 1
petek157
  • 28
  • 3
  • I'm sorry, but where does the 'cloud code' and parse.com comes in? You can use Mailgun API separately of parse.com. I'd suggest you'd use the Objective-C SDK Mailgun provides. Check this link: http://blog.mailgun.com/objective-c-mailgun-sdk-now-available/ Also, and I'm not really sure about this, you may have a problem uploading the pdf via Mailgun. There, you can use Parse.com, get a link and use that in Mailgun API. – Gyfis Sep 19 '14 at 23:08
  • 1
    The Obj-C mailgun SDK also does not seem to allow you to put a pdf as an attachment either just PNGFileType, JPEGFileType. Ive seen posts of others sending pdf via Mailgun I just can't figure out how to get from the state the pdf file is in the code above to the mail gun format. The reason that I am using parse.com's cloud code is to put functionality in the cloud. That way if I decide to build this app for other platforms I don't have to re-write the functionality, just call the cloud function. – petek157 Sep 20 '14 at 15:11

0 Answers0