Re: Sending email using Pantomime
Re: Sending email using Pantomime
- Subject: Re: Sending email using Pantomime
- From: Ludovic Marcotte <email@hidden>
- Date: Fri, 09 Apr 2004 13:03:56 -0400
Hi Thierry,
I would like to send email using pantomime frameworks, but i am
experiencing
a problem.
Here is my code :
ToRecipient *toAddress = [[ToRecipient alloc]
initWithString:@"email@hidden"];
InternetAddress *fromAddress = [[InternetAddress alloc]
initWithString:@"email@hidden"];
Message *messageObj = [[Message alloc] init];
SMTP *smtpObj = [[SMTP alloc] initWithName:@"smtp.server.com"
port:25];
//[smtpObj authenticateWithUsername:@"thierry" password:nil
mechanism:nil];
NSString *emailContents = [NSString stringWithString:@"hello world"];
[messageObj setContentType:@"TEXT/PLAIN"];
[messageObj setCharset:@"CHARSET=utf-8"];
No need to specify "charset=", just do:
[messageObj setCharset:@"utf8"];
[messageObj addToRecipients:toAddress];
[messageObj setFrom:@"CurrenciesConverter"];
-setFrom: accepts an InternetAddress instance, not a NSString
instance. You rather want to do:
[messageObj setFrom: fromAddress];
[messageObj setSubject:@"CurrenciesConverter"];
[messageObj setContentFromRawSource:[emailContents
dataUsingEncoding:NSUTF8StringEncoding]];
-setContentFromRawSource serves a different purpose, don't do that.
Instead, let Pantomime do it for you. Just do:
[messageObj setContent: emailContents];
[snip]
The rest seems ok. HTH and thanks a lot,
Ludo
--
Live as if you were to die tomorrow.
Learn as if you were to live forever.
- Gandhi
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.