Ok, so this one is a bit strange....
I have an HTML page in Safari which I want to send as an email. If I go the FILE menu and select "Mail Contents of this Page", it transfers as expected and looks correct.
However, if I use Scripting Bridge add recipients to the outgoing message, it adds the following code to the top of the message content area for EACH recipient added. In one example, with 24 recipients added, the resulting email contains 24 sequential repeats of the following code:
<div style=3D"font-family: = Helvetica; font-size: 12px; color: black; text-align: left;">
<br =class=3D"webkit-block-placeholder"></div>
which because of the way the div tag is rendered, creates 24 line breaks at the beginning of the email so that my HTML begins further down the page.
Anyone know why this code is getting inserted?
Here is the code I'm using for Scripting Bridge:
SafariDocument *safariDoc = [[[[safari classForScriptingClass:@"document"] alloc]
initWithProperties:[NSDictionary dictionaryWithObject:@"//private/var/tmp/mail.html" forKey: @"URL"]] autorelease];
[[safari documents] addObject:safariDoc];
SafariWindow *safariWindow = [[safari windows] objectAtIndex:0];
[safariWindow emailContentsOf:safariWindow.currentTab];
mailMessage = [[[mail outgoingMessages] objectAtIndex:0] autorelease];
Here is the code I use to add recipients:
MailToRecipient *recipient = [[[[mail classForScriptingClass:@"to recipient"] alloc]
initWithProperties:[NSDictionary dictionaryWithObjectsAndKeys:
[preferencesData bandName], @"name",
[preferencesData bandEmail], @"address",
nil]] autorelease];
[[mailMessage toRecipients] addObject:recipient];
* EDIT *
I have found a work around for the problem, but I would still be interested in knowing WHY this code is getting inserted into the body when I add a recipient... The work around is as follows: I inserted the following into the CSS section of my HTML template...
div {
display:none;
}
Thus, the display ignores all of the div tags in the html template. I still have 24 copies of the above code, but they are essentially ignored which solves my visual layout problem.
If anyone has a better solution, please let me know!