Hi
I am trying to send the contents of a webwiew with email. I have found
several ways to do that, but there are minor problems.
// get the attributes string of the webview
id res = (id <WebDocumentText> )[[[myWebView mainFrame] frameView]
documentView];
NSAttributedString *p = [res attributedString];
NSPasteboard *pb = [NSPasteboard pasteboardWithName:@"PBtoMail"];
// init a private pastebord for data transfer, this time use
webarchive for transfer
[pb declareTypes:[NSArray arrayWithObject:NSRTFDPboardType]
owner:self];
// convert the attributed string to rtfd and place it on the private
pasteboard
NSRange range;
range.location = 0;
range.length = [p length];
[pb setData:(NSData *)[p RTFDFromRange:range documentAttributes:nil
forType:NSRTFDPboardType];
// open mail window using the rtfd data using services...
NSPerformService(@"Mail/Send Selection", pb);
This works, but quality is no so good. So I tried a different approach
// init a private pastebord for data transfer, this time use
webarchive for transfer
NSPasteboard *pb = [NSPasteboard pasteboardWithName:@"PBtoMail"];
[pb declareTypes:[NSArray arrayWithObject:WebArchivePboardType]
owner:self];
// get the webarchive and place it on pboard
[pb setData:[[[myWebView mainFrameDocument] webArchive] data]
forType:WebArchivePboardType];
NSPerformService(@"Mail/Send Selection", pb);
This works better. However external CSS code is not copied, which
makes the page look different. When I select all and copy from the
webview manualy and then paste it on a new mail window it works fine,
the external CSS is copied as well. Is there any way I get the full
source (including the external CSS) so that I can place it on the
pasteboard?
Thanks in advance.
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]