-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSendMail.m
55 lines (44 loc) · 1.54 KB
/
SendMail.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// SendMail.m
// Toucan
//
// Created by will on 17/03/10.
// Copyright 2010 ExoApps. All rights reserved.
//
#import "SendMail.h"
@implementation SendMail
@synthesize filesPaths;
- (void)dealloc
{
self.filesPaths = nil;
[super dealloc];
}
- (void)sendTheMail
{
NSDictionary * error = nil;
NSMutableString * theScript = [NSMutableString string];
NSMutableString * filesName = [NSMutableString string];
for(NSString * item in self.filesPaths) [filesName appendFormat: [NSString stringWithFormat: @"%@, ", [item lastPathComponent]]];
[theScript appendFormat:
@"tell application \"Mail\"\n"
"set theMessage to make new outgoing message with properties {visible:true, subject:\"%@\", content:(ASCII character 10) & (ASCII character 10) & (ASCII character 10) & \"%@\" & (ASCII character 10) & (ASCII character 10)}\n"
"tell content of theMessage\n",
[NSString stringWithFormat: NSLocalizedString(@"SEND_MAIL_SUBJECT",@"Images : %@"), filesName],
NSLocalizedString(@"SEND_MAIL_BODY",@"Envoyé depuis Toucan : http://www.wills-portal.com")
];
for(NSString * item in self.filesPaths)
{
[theScript appendFormat: [NSString stringWithFormat: @"make new attachment with properties {file name:\"%@\"} at after last paragraph\n", item]];
}
[theScript appendString:
@"end tell\n"
"theMessage activate\n"
"end tell"
];
NSAppleScript * script = [[NSAppleScript alloc] initWithSource: theScript];
[script executeAndReturnError: &error];
DLog(@"%@", theScript);
[script release];
script = nil;
}
@end