advertisement

Article:
  Working with Sheets in Cocoa
Subject:   Extension: Sending email from Address Book
Date:   2002-01-02 21:28:53
From:   michele
Response to: Extension: Sending email from Address Book

Changed the code as follows :


// For sending mail
- (IBAction) sendMail: (id) sender
{
NSMutableString *url = [NSMutableString stringWithString: @"mailto:"];
NSString *str;
NSEnumerator *enumerator;
NSNumber *index;


// Check if there is a selected row
if ([tableView numberOfSelectedRows] == 0)
{
return;
}


// Enumerate all selected rows
enumerator = [tableView selectedRowEnumerator];


// Traverse the selected rows with enumerator
while ( ( index = [enumerator nextObject] ) )
{
// Retrieve the email field
str = [[records objectAtIndex: [index intValue]]
objectForKey: @"Email"];
// Add a comma to separate email addresses if this is not the first one
if (![url isEqualToString: @"mailto:"])
{
[url appendString: @","];
}
// Add the email address to the previously built string
[url appendString: str];
}