views:

98

answers:

1

I am trying to send a faceless email (sending an email without showing the interface), using the code below.

I also want to attach an image to this email.

Is this possible?

- (void) sendEmailTo:(NSString *)toStr withSubject:(NSString *)subjectStr withBody:(NSString *)bodyStr
{
    NSString *emailString=[[NSString alloc] initWithFormat:@"mailto:?to=%@&subject=%@&body=%@",
                           [toStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
                           [subjectStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
                           [bodyStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:emailString]];

    [emailString release];
}
+4  A: 

You are unable to send faceless emails using the built-in emailer. However you should be able to roll your own emailer using parts from email frameworks like for instance Pantomime

Claus Broch
Note that with an email framework, you will need to provide an SMTP server, and will not have access to Mail's SMTP configuration. This is intentional. Apple does not want you to send mail quietly on the user's behalf, and definitely doesn't want to quietly give you their email address or grant you access to their SMTP server. You will need to make certain that your email feature is very clear to the user and that the user has control over whether emails are being sent.
Rob Napier
@Rob Absolutely agree on that
Claus Broch
Will apple allows the using of third party frameworks in their apps???sending email in background which apple does not allow in their frameworks will be sanctioned by them???
anurag
You may use any third-party frameworks that doesn't breach their policies otherwise. I don't think sending faceless emails by itself is prohibited as long as you play nicely as Rob commented. If it is prohibited, then they might as well prohibit any network transactions posting stuff to websites, middleware services, etc.
Claus Broch
@ClausClaus have u ever used the pantomime framework in ur application??Actually I have never used a third party framework in my applications.So I will be very thankful to u if u can suggest ....How I can Download and use Pantomime in my application.
anurag
I have never used the entire framework before, but I have used parts from it - including the SMTP sender in a Mac application. I suggest you download the source from the link in the answer and have a look at how it works.
Claus Broch