• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scripting Bridge and multiple attachments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Bridge and multiple attachments


  • Subject: Re: Scripting Bridge and multiple attachments
  • From: Graham Cox <email@hidden>
  • Date: Tue, 1 Sep 2009 17:44:21 +1000

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 (email@hidden)

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:
This email sent to email@hidden


References: 
 >Scripting Bridge and multiple attachments (From: Israel Chauca Fuentes <email@hidden>)

  • Prev by Date: Re: "Format not a string literal and no format arguments"
  • Next by Date: Re: Snow Leopard bug?
  • Previous by thread: Scripting Bridge and multiple attachments
  • Next by thread: Re: Scripting Bridge and multiple attachments
  • Index(es):
    • Date
    • Thread