over 7 years ago
Following code can be use to send email in mac os:
-(IBAction)sendEmailClicked:(id)sender { NSString *recipient; NSString *mailsender; NSString *mailsubject; NSString *mailmessage; recipient = [reciever stringValue]; mailsender = [_sender stringValue]; mailsubject = [subject stringValue]; // mailmessage = messageBody strin // NSString *bodyText = @"Your body text \n\r"; BOOL (^checkEmail)(NSString *email); checkEmail = ^BOOL(NSString *email) { NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; return [predicate evaluateWithObject:email]; }; if(!checkEmail(recipient)) { NSLog(@"INVALID RECIPIENT EMAIL."); [self alert:@"Invalid recipient email."]; return; } else if(!checkEmail(mailsender)) { NSLog(@"INVALID SENDER EMAIL."); [self alert:@"Invalid sender email."]; return; } NSString *emailString = [NSString stringWithFormat:@"\ tell application \"Default Mail\"\n\ set newMessage to make new outgoing message with properties {subject:\"%@\", content:\"%@\" & return} \n\ tell newMessage\n\ set visible to false\n\ set sender to \"%@\"\n\ make new to recipient at end of to recipients with properties {name:\"%@\", address:\"%@\"}\n\ tell content\n\ ",mailsubject, mailmessage, @"McAlarm alert", @"McAlarm User", mailsender]; NSMutableArray *attachments = [[NSMutableArray alloc]init]; [attachments addObject:[imageEdWindowController getImageLocation]]; //add attachments to script for (NSString *filePath in attachments) { emailString = [emailString stringByAppendingFormat:@"make new attachment with properties {file name:\"%@\"} at after the last paragraph\n\ ",filePath]; NSLog(@"emailString:%@",emailString); } //finish script emailString = [emailString stringByAppendingFormat:@"\ end tell\n\ send\n\ end tell\n\ end tell"]; NSAppleScript *emailScript = [[NSAppleScript alloc] initWithSource:emailString]; NSLog(@"emailScript:%@",emailScript); [emailScript executeAndReturnError:nil]; NSLog(@"emailScriptExecuted"); [[self window]close]; }
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)