Sunday, May 9, 2021

#1 2021-03-18 06:59:28 am

jnkendal
Member
Registered: 2006-10-07
Posts: 6

Message header in body of Mail

Hello everyone
Years ago, one of the members kindly provided me with a script that produce the following in the body of a Mail message:

DE VJNK NR 08130/04
R 091019Z MAY08
FM KENDAL JN
TO
BT
UNCLAS

BT







NNNN

Unfortunately the attached script no longer works. Would it be possible for anyone to "tweet" the script to get it to work. I am using Mac Catalina v10.15.7.
Thanks in advance:

property lastDate : ""
property lastMsgNo : 0

set jDay to do shell script "date +%j"
set jYear to do shell script "date +%y"
set theSubject to jYear & jDay & "/"

set theYEar to do shell script "date +%y" -- two digit year
set theMonth to do shell script "date +%m" -- two digit month
set theMonth2 to (do shell script "date +%B" & " | tr \"[:lower:]\" \"[:upper:]\"")
set theDay to do shell script "date +%d" -- two digit day of month
set theHour to do shell script "date +%H" -- two digit hour (24 hour clock)
set theMinute to do shell script "date +%M" -- two digit minute
set theSecond to do shell script "date +%S" -- two digit second

-- convert the month2 name to a 3 char name
set theMonth2 to characters 1 thru 3 of theMonth2 as string

set currentDate to jYear & jDay -- get current date

if lastDate = "" then -- i.e. first run of script
    set lastDate to jYear & jDay
end if

if lastDate = currentDate then
    set lastMsgNo to lastMsgNo + 1
else
    set lastMsgNo to 1
    set lastDate to currentDate
end if

set msgNo to text -2 thru -1 of (("00" & lastMsgNo) as string) -- make 2 digit number

set theSubject to currentDate & "/" & msgNo

set theBody to "DE VJNK NR " & jYear & jDay & "/" & msgNo & return ¬
    & "R " & theDay & theHour & theMinute & "Z " & theMonth2 & theYEar & return ¬
    & "FM KENDAL JN" & return ¬
    & "TO" & return ¬
    & "BT" & return ¬
    & "UNCLAS" & return & return ¬
    & "BT" & return & return & return & return & return & return & return & return ¬
    & "NNNN"

tell application "Mail"
    activate
    set theNewMessage to make new outgoing message with properties {subject:theSubject, content:theBody}
    tell theNewMessage to set visible to true
    -- Default is false. Determines whether the compose window will
    -- show on the screen or whether it will happen in the background.
end tell

Offline

 

#2 2021-03-18 11:22:27 pm

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1788

Re: Message header in body of Mail

Hi,

Your script works fine, if you remove character  (which is not UTF-8 encoded symbol):

Applescript:


property lastDate : ""
property lastMsgNo : 0

set jDay to do shell script "date +%j"
set jYear to do shell script "date +%y"
set theSubject to jYear & jDay & "/"

set theYEar to do shell script "date +%y" -- two digit year
set theMonth to do shell script "date +%m" -- two digit month
set theMonth2 to (do shell script "date +%B" & " | tr \"[:lower:]\" \"[:upper:]\"")
set theDay to do shell script "date +%d" -- two digit day of month
set theHour to do shell script "date +%H" -- two digit hour (24 hour clock)
set theMinute to do shell script "date +%M" -- two digit minute
set theSecond to do shell script "date +%S" -- two digit second

-- convert the month2 name to a 3 char name
set theMonth2 to characters 1 thru 3 of theMonth2 as string

set currentDate to jYear & jDay -- get current date

if lastDate = "" then -- i.e. first run of script
   set lastDate to jYear & jDay
end if

if lastDate = currentDate then
   set lastMsgNo to lastMsgNo + 1
else
   set lastMsgNo to 1
   set lastDate to currentDate
end if

set msgNo to text -2 thru -1 of (("00" & lastMsgNo) as string) -- make 2 digit number

set theSubject to currentDate & "/" & msgNo

set theBody to "DE VJNK NR " & jYear & jDay & "/" & msgNo & return ¬
   & "R " & theDay & theHour & theMinute & "Z " & theMonth2 & theYEar & return ¬
   & "FM KENDAL JN" & return ¬
   & "TO" & return ¬
   & "BT" & return ¬
   & "UNCLAS" & return & return ¬
   & "BT" & return & return & return & return & return & return & return & return ¬
   & "NNNN"

tell application "Mail"
   activate
   set theNewMessage to make new outgoing message with properties {subject:theSubject, content:theBody}
   tell theNewMessage to set visible to true
   -- Default is false. Determines whether the compose window will
   -- show on the screen or whether it will happen in the background.
end tell

Last edited by KniazidisR (2021-03-18 11:23:25 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

#3 2021-03-25 02:15:54 am

jnkendal
Member
Registered: 2006-10-07
Posts: 6

Re: Message header in body of Mail

Thank you very much.
One (last) question:
How do I make this script available in the top tool bar of my screen?
Cheers and again thanks.

Offline

 

#4 2021-03-25 03:16:17 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 1788

Re: Message header in body of Mail

I am now on the Androiday phone, so cannot provide read_many solution
See https://macscripter.net/viewtopic.php?id=46976 for how to create custom menu


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 14.1
Ram: 4 GB

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)