Skip navigation.
 
mlRe: Sending Email with Attachments
FROM : TACKEL
DATE : Fri Jan 24 18:06:32 2003

Hi,

It's really easy, the most difficult part is to send a file attached.

Take a look a the main function 'deliverMessage'. I forgot to tell you need to add the Message framework.

The messageBody is a NSAttributedString you just need to cast your NSMutableString or init the AttributtedString with it.



+ (BOOL)deliverMessage: (NSAttributedString *)messageBody headers: (NSDictionary *)messageHeaders format: (NSString *)messageFormat protocol: (NSString *)deliveryProtocol;
    //
    // messageBody is the actual contents of the message.  If messageFormat is NSASCIIMailFormat,
    //    any rich text or attachments in messageBody will be lost
    //
    // messageHeaders contains all of the values that will appear in the message header,
    //    for example, "To", "From", "Subject", etc.  If the value is an array, the elements
    //    in the array will converted to a comma seperated list of values in the message header
    //
    // messageFormat can be either NSASCIIMailFormat or NSMIMEMailFormat
    //
    // deliveryProtocol can be NSSMTPDeliveryProtocol
    //  or nil to use the platform's default deliveryProtocol (this is the preferred choice).
    //

Regards,
Tackel




> From: Joseph Jones <<email_removed>>
> Date: Fri, 24 Jan 2003 08:49:41 -0800
> To: TACKEL <<email_removed>>, Cocoa Dev <<email_removed>>
> Subject: Re: Sending Email with Attachments
>
> This look sgreat, and would be perfect except for one thing: I am not
> sending a file but am attaching a generated NSMutableString (as if it wer a
> file). I realize I could write the file to disk, wrap it, attach it, send it
> and then delete it but that sure seems like a lot of extra work. Any ideas
> on how to do this w/o having to manage an external file?
>
> Joe
>
>

>> From: TACKEL <<email_removed>>
>> Date: Fri, 24 Jan 2003 17:33:22 +0100
>> To: <email_removed>, <email_removed>
>> Subject: Re: Sending Email with Attachments
>>
>> Hi Joseph,
>>
>> After some tries that works for me:
>>
>> BOOL sent;
>> NSFileWrapper *fw=[NSFileWrapper alloc];
>> NSTextAttachment *att= [NSTextAttachment alloc];
>>
>>
>> [fw initWithPath: [@"~/Desktop/file.txt" stringByExpandingTildeInPath]];
>> [att initWithFileWrapper:fw];
>>
>>
>>
>> NSMutableDictionary *headers;
>> headers = [NSMutableDictionary dictionary];
>> [headers setObject:@"tackel" forKey:@"From"];
>> [headers setObject:@"<email_removed>" forKey:@"To"];
>> [headers setObject:@"Report" forKey:@"Subject"];
>> [headers setObject:@"Apple Message" forKey:@"X-Mailer"];
>> [headers setObject:@"multipart/mixed" forKey:@"Content-Type"];
>> [headers setObject:@"1.0" forKey:@"Mime-Version"];
>>
>>
>>
>> sent= [NSMailDelivery deliverMessage: [NSAttributedString
>> attributedStringWithAttachment: att] headers: headers format:
>> NSMIMEMailFormat protocol: NSSMTPDeliveryProtocol];
>>
>> Hope it helps.
>>
>> Regards,
>> Tackel.
>>
>>

>>> From: Joseph Jones <<email_removed>>
>>> Date: Thu, 23 Jan 2003 22:21:29 -0800
>>> To: Cocoa Dev Dev <<email_removed>>
>>> Subject: Sending Email with Attachments
>>>
>>> Can anyone point me to an example of sending email with attachments?
>>> There was a thread on sending email here a while ago, though I can;t
>>> seem to locate it in the archives.
>>>
>>> I have looked at EDMessage framework, and while it looks great I can
>>> see no way of using it with an SMTP server that requires login (like
>>> .Mac). I thought there was a simple way of sending mail using
>>> NSWorkspace, but I don't know what it was... :-(
>>>
>>> Thanx,
>>> joe
>>> _______________________________________________
>>> cocoa-dev mailing list | <email_removed>
>>> Help/Unsubscribe/Archives:
>>> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>>> Do not post admin requests to the list. They will be ignored.

_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

Related mailsAuthorDate
mlSending Email with Attachments Joseph Jones Jan 24, 07:21
mlRe: Sending Email with Attachments TACKEL Jan 24, 17:33
mlRe: Sending Email with Attachments Joseph Jones Jan 24, 17:49
mlRe: Sending Email with Attachments TACKEL Jan 24, 18:06
mlRe: Sending Email with Attachments Joseph Jones Jan 25, 00:18
mlRe: Sending Email with Attachments Joseph Jones Jan 25, 03:46
mlRe: Sending Email with Attachments Scott Anguish Jan 25, 05:44
mlFrom header and NSMailDelivery (was Re: Sending Email with Attachments) Alex Rice Feb 4, 07:51
mlRe: From header and NSMailDelivery (was Re: Sending Email with Attachments) j o a r Feb 4, 09:20