Sunday, July 5, 2020

#1 2020-05-11 01:39:41 am

costasppc
Member
Registered: 2008-09-03
Posts: 21

Outlook sent message is in MIME format

Hello,

I have created a script that uses the send variable to send a message with an attachment from Microsoft Outlook. When the message is sent via the script, content is messed up (MIME) and the attachment is not included.

Best regards

Kostas

Offline

 

#2 2020-05-11 02:30:54 am

costasppc
Member
Registered: 2008-09-03
Posts: 21

Re: Outlook sent message is in MIME format

Found the issue: when feeding the subject line with the attachments name (either as text or as string), message is sent as MIME, and this is because the subject comes as filename with the extension. If I remove the extension manually, then the mail goes fine.

Any way of stripping the extension of the file and then feed it to the subject line?

Best regards

Kostas

Offline

 

#3 2020-05-11 03:56:32 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4534

Re: Outlook sent message is in MIME format

Applescript:

set aFile to choose file of type {"public.image"}
tell application "Finder"
   set {itsName, itsExtension} to {name, name extension} of aFile
   set itsPath to path of aFile
end tell
if itsExtension ≠ "" then
   set strippedName to text 1 thru -(2 + (count itsExtension)) of itsName
   set strippedPath to text 1 thru -(2 + (count itsExtension)) of itsPath
else
   set strippedName to itsName
   set strippedPath to itsPath
end if

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 11 mai 2020 11:56:24

Last edited by Yvan Koenig (2020-05-11 08:34:32 am)

Offline

 

#4 2020-05-11 04:18:21 am

costasppc
Member
Registered: 2008-09-03
Posts: 21

Re: Outlook sent message is in MIME format

Thank you very much,

How can I inject this to my script (part of it below)?

Applescript:


on adding folder items to theFolder after receiving theNewItems
   set filesAdded to {}
   tell application "Finder" to set folderName to name of folder theFolder
   repeat with i from 1 to count of theNewItems
       set thisItem to item i of theNewItems
       tell application "Finder"
           set FileName to name of thisItem
           set end of filesAdded to (FileName & linefeed)
       end tell
   end repeat
   activate
   display notification (("Folder: " & theFolder)) with title "Orders Hot Folder" subtitle "Sales Order: " & filesAdded as string

Offline

 

#5 2020-05-11 09:11:28 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4534

Re: Outlook sent message is in MIME format

Applescript:

on adding folder items to theFolder after receiving theNewItems
   set filesAdded to {}
   tell application "Finder" to set folderName to name of folder theFolder
   repeat with thisItem in theNewItems
       tell application "Finder"
           set {fileName, nameExtension} to {name, name extension} of thisItem
       end tell
       if nameExtension ≠ "" then
           set strippedName to text 1 thru -(2 + (count nameExtension)) of fileName
       else
           set strippedName to fileName
       end if
       set end of filesAdded to (strippedName & linefeed)
   end repeat
   --    activate
   --display notification (("Folder: " & theFolder)) with title "Orders Hot Folder" subtitle "Sales Order: " & filesAdded as string
   -- Your message is too long for a notification
   display dialog (("Folder: " & theFolder)) & linefeed & "Orders Hot Folder" & linefeed & "Sales Order: " & filesAdded
end adding folder items to

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 11 mai 2020 17:11:20

Offline

 

#6 2020-05-12 05:01:39 am

costasppc
Member
Registered: 2008-09-03
Posts: 21

Re: Outlook sent message is in MIME format

Thank you, works fine.

However, when any text (other than static) is fed into Outlook subject line, the message is sent garbled.

But this is another issue...

Best regards

Kostas

Offline

 

#7 2020-05-12 09:07:41 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4534

Re: Outlook sent message is in MIME format

May you post an example of the original text and what appear in Outlook?
I assumes that the non-static tex is the result of a concatenation of items with 'exotic' encodings.

Assuming that you concatenate the strings text1, text2 and text3, maybe you may try:

Applescript:

set myText to (text1 & text2 & text3) as «class utf8»

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 12 mai 2020 17:07:31

Offline

 

#8 2020-05-12 11:25:09 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Outlook sent message is in MIME format

costasppc wrote:

However, when any text (other than static) is fed into Outlook subject line, the message is sent garbled.


What does "fed" mean? Fedding should not be in the form of replacing rich text with plain text. To correctly replace parts of rich text, you need to use the Mail.app application itself or Outloook.app (its set subject to... command).

You can replace some "plain text" parts of rich text directly without apps, but you should edit the source of your mails and note the content. You get the source of mail as rich text, edit its parts, then pass this rich text to some application. Passing the content (plain text) of course, does other task...

Last edited by KniazidisR (2020-05-12 12:41:52 pm)


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

Offline

 

#9 2020-05-12 03:18:10 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4534

Re: Outlook sent message is in MIME format

KniazidisR wrote:
costasppc wrote:

However, when any text (other than static) is fed into Outlook subject line, the message is sent garbled.


What does "fed" mean? Fedding should not be in the form of replacing rich text with plain text. To correctly replace parts of rich text, you need to use the Mail.app application itself or Outloook.app (its set subject to... command).

You can replace some "plain text" parts of rich text directly without apps, but you should edit the source of your mails and note the content. You get the source of mail as rich text, edit its parts, then pass this rich text to some application. Passing the content (plain text) of course, does other task...




I doubt that what you wrote here is relevant.
It seems clear that what the OP pass is a piece of text used to define the subject of a new message (maybe he wanted to type something like 'is sent into Outlook subject line')
Like you and me, he is probably not a native English user and the typo we are facing isn't worse than those which we may see in your messages or in mine.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 12 mai 2020 23:15:13

Offline

 

#10 2020-05-13 06:33:02 am

costasppc
Member
Registered: 2008-09-03
Posts: 21

Re: Outlook sent message is in MIME format

by fed I mean to "pass" a variable like:

Applescript:

set varSubjectName to "Order:" & filesAdded as string

whenever I pass the variable filesAdded value to Outlook's subject field, message is sent like below:
I have tried as text, as Unicode text

From: xxxx 
To: 
BCC: 
Message-ID: <6782C8E3-213B-4FFD-9C29-E35C110103DB@i-system.gr>
Thread-Topic: This is an order: This is an order copy 10

Mime-version: 1.0
Content-type: multipart/mixed;
    boundary="B_3672129744_561895651"

> This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

Best regards

Kostas

Last edited by costasppc (2020-05-13 06:34:20 am)

Offline

 

#11 2020-05-13 07:57:20 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4534

Re: Outlook sent message is in MIME format

Thank you.

It seems that I was not clear enough.

I wished to see what appear in the "Outlook subject line" so that I may try to understand what is really passed in this field.

As far as I know,

Applescript:

set varSubjectName to "Order:" & filesAdded as string

is perfectly identical to

Applescript:

set varSubjectName to "Order:" & filesAdded

I'm not aware of the way some “exotic” characters available in the passed pathnames may be treated.
This is why I proposed:

Applescript:

tell application "Finder" to set filesAdded to (the selection) as alias list
set varSubjectName to ("Order:" & filesAdded) as «class utf8»
--> "Order:SSD 1000:Users:**********:Desktop:Save as PDF.txtSSD 1000:Users:**********:Desktop:shapes names.txt"

to be sure that everything would be encoded as utf8.

At this time I just know what I already knew : the created message is in MIME format.
As I continue to ignore what is in the "Outlook subject line" I can't try to help.

Maybe it's an “exotic” character, maybe it's the embedded colons (or the embedded slashes if you pass POSIX paths) …

You may try to use something like:

Applescript:

tell application "Finder" to set filesAdded to (the selection) as alias list

set varSubjectName to ("Order:" & filesAdded) as «class utf8»
--> "Order:SSD 1000:Users:**********:Desktop:Save as PDF.txtSSD 1000:Users:**********:Desktop:shapes names.txt"
set varSubjectName to my remplace(varSubjectName, {":", "/"}, "-") -- replace embedded slash(es) or colon(s) by "-"
--> "Order-SSD 1000-Users-**********-Desktop-Save as PDF.txtSSD 1000-Users-**********-Desktop-shapes names.txt"

#=====
(*
replaces every occurences of d1 by d2 in the text t
*)

on remplace(t, d1, d2)
   local oTIDs, l
   set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d1}
   set l to text items of t
   set AppleScript's text item delimiters to d2
   set t to l as text
   set AppleScript's text item delimiters to oTIDs
   return t
end remplace

#=====

If it works we would know that the culprit was the delimiter used in the pathnames.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 13 mai 2020 15:55:13

Offline

 

#12 2020-05-13 08:02:03 am

costasppc
Member
Registered: 2008-09-03
Posts: 21

Re: Outlook sent message is in MIME format

Thank you,

In the outlook subject line appears the static text ("Order:") along with the filename of the hotfolder  (& filesAdded as string).

Example: Order: filename 01

When the subject has only the static text, all is OK. When the filesAdded value is added, mail message becomes MIME format.

Best regards

Kostas

Offline

 

#13 2020-05-13 08:33:53 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4534

Re: Outlook sent message is in MIME format

costasppc wrote:

Thank you,

In the outlook subject line appears the static text ("Order:") along with the filename of the hotfolder  (& filesAdded as string).

Example: Order: filename 01

When the subject has only the static text, all is OK. When the filesAdded value is added, mail message becomes MIME format.

Best regards

Kostas


OK. I thought that filesAdded was a list of pathnames.
May you try to replace :

Applescript:

set varSubjectName to "Order:" & filesAdded as string

by

Applescript:

set varSubjectName to "Order: filename 01"

If it gives the same odd behavior, maybe the field isn't allowed to contain space character or digit.

Try with:

Applescript:

set varSubjectName to "Order: filename "

then with

Applescript:

set varSubjectName to "Order:filename"

and at last with

Applescript:

set varSubjectName to "Order:filename01"

I know that my proposals don't match what you really want to pass but we are trying to understand what is the cause of the annoying described behavior.
If one of the proposed versions behaves well we would know that the contents of filesAdded can't be passed in the Subject field but may only be in the body of the message.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 13 mai 2020 16:33:26

Offline

 

#14 2020-05-13 08:44:34 am

costasppc
Member
Registered: 2008-09-03
Posts: 21

Re: Outlook sent message is in MIME format

Thank you,

Its not a character limit issue, since I have added a date, like:

Applescript:

current date --> date "Saturday, April 15, 2006 4:29:04 PM"
   set varSubjectName to "Order: " & (current date)

which result to subject name:
Order: Wednesday, 13 May 2020 at 17:42:58

this message is sent fine (no garbling).

Best regards

Kostas

Offline

 

#15 2020-05-13 09:53:01 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4534

Re: Outlook sent message is in MIME format

Is it possible that there is one or several control character(s) in the filename?
I don't know if such character will be correctly passed in the editor of this forum but I try.

Applescript:

set varSubjectName to "Order: filename 01"

set theIDs to {}
repeat with aChar in every text item of varSubjectName
   set end of theIDs to id of aChar
end repeat
return theIDs
{79, 114, 100, 101, 114, 58, 32, 102, 1, 105, 2, 108, 3, 101, 4, 110, 5, 97, 6, 109, 7, 101, 8, 32, 16, 48, 17, 49, 18}

Replace the first instruction by your original one:

Applescript:

set varSubjectName to ("Order:" & filesAdded)

You will see if there is one or several control character(s) in the file name.

In mine there are ctrl 1, ctrl 2, ctrl 3, ctrl 4, ctrl 5, ctrl 6, ctrl 7, ctrl 8, ctrl 16, ctrl 17 and ctrl 18.
These characters are present but aren't displayed, except in some WordProcessor applications (like Pages for instance).

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 13 mai 2020 17:51:57

Alas, as I feared, the editor of this forum dropped the control characters available in my original script. If you save my script as .applescript one, you may easily insert some of them in an hexadecimal editor. I used “Hex Fiend” to do that.

Last edited by Yvan Koenig (2020-05-13 09:57:38 am)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)