how do I save mail message as rich text?

G’day

I need to save a mail message to a desktop folder as rich text format (rtfd)

The menu allows a ‘Save as’ as rtfd, but how do I write the code to either save, copy or duplicate the message as rtfd?

The first line below works, the second bombs.

Thanks

Santa


duplicate AMessage to folder FolderDateName of desktop
save AMessage in folder FolderDateName as "rtfd"

Hi Santa,

unfortunately you can’t save messages as RTF text unless you create the RTF code manually on the fly.

Take a look at Andreas Amann’s mail scripts, he also published the Xcode source of his project.
In the Archive Messsage script the RTF code will be created by the script itself.

G’day

Sorry to revive an old subject, but I really need to save mail as rtf with embedded attachments.

I’ve got some of the GUI scripting for the Save sheet in mail OK, but the ‘Where’ and the ‘Format’ boxes elude me.

Could someone please advise me how to script these in the following script, and if possible, show me how to save to a path to a folder on the desktop rather than the desktop itself.

Any help much appreciated.

Regards

Santa


set TheDesktop to path to desktop
tell application "Mail"
	activate
	set t to message 1 of mailbox "Trash"
	open t
	tell application "System Events" to tell process "Mail"
		keystroke "s" using {command down, shift down}
		tell window 1
			set value of text field 1 of sheet 1 to "test mail"
			set temp to value of checkbox "Include Attachments" of group 1 of sheet 1
			if temp = 0 then click checkbox "Include Attachments" of group 1 of sheet 1
			
			-- I want to ensure 'Desktop' (or a desktop folder) is selected
			-- also ensure a save as rich text format.
			
		end tell
	end tell
end tell

Tis OK, I solved it.

Santa



tell application "Mail"
	activate
	set t to message 1 of mailbox "Trash"
	open t
	tell application "System Events" to tell process "Mail"
		keystroke "s" using {command down, shift down}
		tell window 1
			set value of text field 1 of sheet 1 to "test mail"
			if value of checkbox "Include Attachments" of group 1 of sheet 1 = 0 then click checkbox "Include Attachments" of group 1 of sheet 1
			
			tell pop up button 1 of sheet 1
				repeat until exists
					delay 0.2
				end repeat
				click
				tell menu 1
					click menu item "Desktop"
				end tell
				
			end tell
			
			tell group 1 of sheet 1
				tell pop up button 1
					repeat until exists
						delay 0.2
					end repeat
					click
					tell menu 1
						click menu item 1
					end tell
				end tell
			end tell
			
		end tell
	end tell
end tell


Actually, i had to make a small correction, as inserting a value into the text field stopped the ‘Save’ button being hilited.


tell application "Mail"
	activate
	set t to message 1 of mailbox "Trash"
	open t
	tell application "System Events" to tell process "Mail"
		keystroke "s" using {command down, shift down}
		tell window 1
			repeat until exists
				delay 0.2
			end repeat
			select text field 1 of sheet 1
			keystroke "test mail 4"
			if value of checkbox "Include Attachments" of group 1 of sheet 1 = 0 then click checkbox "Include Attachments" of group 1 of sheet 1
			
			tell pop up button 1 of sheet 1
				repeat until exists
					delay 0.2
				end repeat
				click
				tell menu 1
					click menu item "Desktop"
				end tell
				
			end tell
			
			tell group 1 of sheet 1
				tell pop up button 1
					repeat until exists
						delay 0.2
					end repeat
					click
					tell menu 1
						click menu item 1
					end tell
				end tell
			end tell
			keystroke return
		end tell
	end tell
	close window 1
end tell