Question

How can i retrieve email body, recipient email address, subject etc of outgoing mail.

thanks for any help.

EDIT:- I have added one custom button in outgoing mail toolbar see image.

enter image description here

And the functionality of that button is send mail and save all mail detail on my server also so how can i get that detail like, both email addresses "To"="test@gmail.com" and "cc"="test2@gmail.com", subject="My subject" , and email body="My email body"

How can i achieve this ?

Was it helpful?

Solution

Through this apple script you can retrieve mail content so please try it.

tell application "System Events"
    tell process "Mail"
        set _Contents to {}
        set _contentDetail to {}
        set the _contentDetail to entire contents of UI element 1 of scroll area 3 of window 1
        repeat with _value in _contentDetail
            set str to ""
            if class of _value is static text then
                set str to value of _value
            end if
            set str to str & return
            set _Contents to _Contents & str

        end repeat
        return get _Contents as string
    end tell
end tell
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top