Re: Extract Text From NSLabels to Mail
Re: Extract Text From NSLabels to Mail
- Subject: Re: Extract Text From NSLabels to Mail
- From: Ken Thomases <email@hidden>
- Date: Fri, 17 Sep 2010 07:13:13 -0500
On Sep 17, 2010, at 6:37 AM, PJBorges wrote:
> In my app I have a feature that opens Mail.app. The feature extracts
> the contents of a number of labels into the message area of Mail, but
> it is only the first label that is extracted, the rest are not.
>
>
> My code:
> MailOutgoingMessage *emailMessage =
> [[[mail classForScriptingClass:@"outgoing message"] alloc]
> initWithProperties:
> [NSDictionary dictionaryWithObjectsAndKeys:
> [self.subjectField stringValue], @"subject",
> [self.sumHours stringValue], @"content",
> [self.sumBooks stringValue], @"content",
> [self.sumMagazines stringValue], @"content", nil]];
>
> How can I extract more than one label?
You are building a dictionary. For any given key (like "content"), a dictionary may only have one value, although the value may be a collection (but probably not in this case).
You probably want to construct a single string from the respective fields. How you want to do that -- that is, the actual content you want the mail message to have -- is up to you. A likely technique would be to format the fields together with something like:
NSString* content = [NSString stringWithFormat:@"%@\n%@\n%@\n", [self.sumHours stringValue], [self.sumBooks stringValue], [self.sumMagazines stringValue]];
Cheers,
Ken
_______________________________________________
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