I don't have an answer, but I recently did the same thing, and found that all my attachments end up at the beginning of the file, ahead of the text, no matter what I did. Here's my code, which is slightly different, but basically semantically identical to yours.

                iter = [[self attachments] objectEnumerator];
                
                NSString*       file;
Class attachmentClass = [appleMail classForScriptingClass:@"attachment"];
                mailAttachment* attachment;
                                
                while(( file = [iter nextObject]))
                {
                        rec = [NSDictionary dictionaryWithObject:file 
forKey:@"fileName"];
                        attachment = [[attachmentClass alloc] 
initWithProperties:rec];
                        [[[message content] attachments] addObject:attachment];
                        [attachment release];
                }

Trying to control applications through Applescript is like trying to perform brain surgery through a letter-box.

--Graham





On 01/09/2009, at 2:49 AM, Israel Chauca Fuentes wrote:

Hi there!

I'm using scripting bridge to send emails with Mail.app and I have managed to do so, but I still have a little problem.

When adding attachments, the first one is placed at the beginning of the message, while the rest of them are placed at the end of the message, which is certainly odd. I would like to place all attachments at the end of the message, which is how I use to place them by hand, but I don't know how.

The code that adds the attachments is the following:
_______________

for ( NSString* path in [self.attachments componentsSeparatedByString: @"\n"] ) {
        
        /* add an attachment, if one was specified */
        if ( [path length] > 0 ) {
                
                /* create an attachment object */
MailAttachment *theAttachment = [[[mail classForScriptingClass:@"attachment"] alloc] initWithProperties: [NSDictionary dictionaryWithObjectsAndKeys: path, @"fileName", nil]];
                
                /* add it to the list of attachments */
                [[emailMessage.content attachments] addObject: theAttachment];
        }
}


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to