Screaming.Pict

Q: Mail.app- 'Remove Attachments' corrupting mails

I have a weird issue that I've not seen mentioned anywhere. Wondering if anyone can give me any debugging tips.

 

I'm using Mail 5.0 in Lion 10.6.1 (issue was occurring in 10.6.0 as well).

 

I have Mail connected to Exchange Server 2010.

 

I have a fairly tight restriction on mailbox sizes so I have to remove attachments from emails before I file them.

 

My problem is this; about 1 in 3 times I remove an attachment the 'replacement' e-mail is full of gibberish characters.

 

Typically if I look at the raw source of the e-mail then the text version of the mail is retained correctly- it seems to be the Base64 encoded version that is corrupted.

 

Any idea what I can do to debug this? I have tried removing the envelope files and removing/adding the account back in and re-syncing it but the issue has reappeared.

 

I've reported this to Apple on http://bugreports.apple.com but have not had a response.

 

Thanks in advance.

Unibody MacBook Pro 15" 2.8GHz, Mac OS X (10.6.1)

Posted on Aug 22, 2011 7:48 AM

Close

Q: Mail.app- 'Remove Attachments' corrupting mails

  • All replies
  • Helpful answers

first Previous Page 6 of 8 last Next
  • by thanimal,

    thanimal thanimal Mar 25, 2015 12:57 PM in response to Edward Tewkesbury
    Level 1 (4 points)
    Mar 25, 2015 12:57 PM in response to Edward Tewkesbury

    I've been using Mail to access remote IMAP email for years and I never encountered this problem -- until I bought a new iMac recently, and suddenly I am encountering this problem (Mail 8.2 on Yosemite 10.10.2). I suppose it could be related to a coincident change in our company's mail server, however.

     

    I'm glad to hear there's a way of fixing the problem. However  the problem occurs fairly infrequently for me, and I am not inclined to go editing the affected emails -- especially given that I have a few different accounts on separate, remote IMAP servers. I have found that I can at least view the message body without it being garbling into Chinese and special characters by selecting "View > Message > Raw Source" in Mail.

  • by trewq321,

    trewq321 trewq321 Apr 1, 2015 10:05 AM in response to thanimal
    Level 1 (0 points)
    Apr 1, 2015 10:05 AM in response to thanimal

    4 years after this problem was first reported, it is still a big problem in Yosemite. Apple store staff say they have never seen it before (3 staff) and sent me to the "Genius Bar". The Genius simply dismissed the problem blaming the fact that i was using gmail with apple's mail and calendar apps; and told me that i needed to contact gmail to resolve the problem! I felt under pressure to use an iCloud email address, which, after years of using a gmail address for all my academic work (very successfully with windows and outlook) is something i don't think i should have to do.

  • by thanimal,

    thanimal thanimal Apr 1, 2015 10:11 AM in response to trewq321
    Level 1 (4 points)
    Apr 1, 2015 10:11 AM in response to trewq321

    I use gmail too, but not for all of my email. And I certainly have had instances of this problem occurring as recently as March 26, 2015 in a work email account that I read directly with Mail (IMAP). So I don't buy their assertion that it is a gmail problem.

  • by trewq321,

    trewq321 trewq321 Apr 1, 2015 10:13 AM in response to thanimal
    Level 1 (0 points)
    Apr 1, 2015 10:13 AM in response to thanimal

    thanks for this information

  • by Bruce 55,

    Bruce 55 Bruce 55 Apr 1, 2015 3:08 PM in response to trewq321
    Level 1 (4 points)
    Apr 1, 2015 3:08 PM in response to trewq321

    With all respect to the apple genius - this issue is not relevant to gmail or any other it is an apple mail issue about how mail handles the deletion of the attachments. I have tried to find a pattern like is it only when attachments are in received gmails or any other but it is indescriminent.

     

    If you read this thread from the beginning you will see that some very knowlegable folks have looked at this and if not been able to give a fix, but provided a very simple work around that will help you.

     

    If after 4 years the apple engineers have not sorted this out it sounds like it is not an issue for them or a priority

  • by hr101,

    hr101 hr101 Apr 2, 2015 11:22 AM in response to felix the cat!
    Level 1 (0 points)
    Apr 2, 2015 11:22 AM in response to felix the cat!

    I wondered if an AppleScript could help automate but a kind board user offered another work around which works for me if anyone wishes to try as well.Re: Wanted: can the following OS fix be scripted and is anyone willing?

  • by Rich In Space,

    Rich In Space Rich In Space Apr 7, 2015 10:18 AM in response to Screaming.Pict
    Level 1 (30 points)
    Apr 7, 2015 10:18 AM in response to Screaming.Pict

    Got tired of waiting for Apple to fix this attachment issue, so I put together a simple AppleScript. It's free for anyone to use, but no warranties are given. To try it do the following:

    1. Create a new AppleScript file using Script Editor
    2. Copy my script below (all text between the long lines) into the file
    3. Save it in your folder ~/Library/Scripts/Applications/Mail/ (or create that folder if needed) and give it some suitable name
    4. In Script Editor, make sure you have turned ON the preference checkbox "Show Script menu in menu bar"

    Now you can just select any corrupted email in Mail and run this AppleScript from the Script menu. And voila, your mail should be fixed.

    (The Script menu will change into a rotating cog wheel when the script is still executing. It might take a second or two since it needs to fire up TextEdit to do the text replacements, so be patient.)

     

    -----------------------------------------------------

    --Creator: Rich In Space, 7th April 2015

    tell application "Mail"

      set theMsgs to the selection

      repeat with theMsg in theMsgs

      set mID to id of theMsg

     

      if my isBadEncoding(theMsg) then

      set theDir to POSIX path of (path to library folder from user domain) & "Mail/V2/"

      set shellScr to "mdfind -onlyin " & theDir & " 'kMDItemFSName == " & quote & mID & ".emlx" & quote & "'"

      set mPath to do shell script shellScr

      if mPath ≠ "" then my FixEnc(POSIX file mPath as string)

      end if

      end repeat

    end tell

     

    on isBadEncoding(theMsg)

      tell application "Mail" to set theCont to content of theMsg

      set theContSum to summarize theCont

     

      if length of theContSum ≥ 10 then

      set chars to 10

      else

      set chars to length of theContSum

      end if

      set checkSum to 0

      repeat with i from 1 to chars

      set checkSum to checkSum + (id of character i of theContSum)

      end repeat

     

      return checkSum / chars > 256

    end isBadEncoding

     

    on FixEnc(mPath)

      tell application "TextEdit"

      open file mPath

     

      set EncPar to "Content-Transfer-Encoding: base64

    "

      set every paragraph of front document where it = EncPar to ""

     

      save front document

      close front document saving yes

      end tell

    end FixEnc

    -----------------------------------------------------

  • by Bruce 55,

    Bruce 55 Bruce 55 Apr 7, 2015 6:42 PM in response to Rich In Space
    Level 1 (4 points)
    Apr 7, 2015 6:42 PM in response to Rich In Space

    Rich-in-Space,

     

    Thanks for the workaround

     

    I have done exactly as you have suggested but all I end up with after the script runs is the eamil and all html in raw code - no gibberish just the email un formatted

     

    Any clues on this

  • by Rich In Space,

    Rich In Space Rich In Space Apr 8, 2015 1:02 AM in response to Bruce 55
    Level 1 (30 points)
    Apr 8, 2015 1:02 AM in response to Bruce 55

    Yes, there is another user reporting the same thing – text showing up as HTML. It seems you have an encoding problem different from mine. But I'll have a look at it and see if I can find a quick fix.

  • by Bruce 55,

    Bruce 55 Bruce 55 Apr 8, 2015 1:07 AM in response to Rich In Space
    Level 1 (4 points)
    Apr 8, 2015 1:07 AM in response to Rich In Space

    Currently I am removing the "base64" at the end of the email in text edit - it would be lovely to have a script to do this as it is a right royal pain in the ...... right now - so thanks for looking into it - much appreciated.

  • by Rich In Space,

    Rich In Space Rich In Space Apr 8, 2015 6:20 AM in response to Bruce 55
    Level 1 (30 points)
    Apr 8, 2015 6:20 AM in response to Bruce 55

    Bruce 55 wrote:

    Currently I am removing the "base64" at the end of the email in text edit - it would be lovely to have a script to do this as it is a right royal pain in the ...... right now - so thanks for looking into it - much appreciated.

    This is exactly what the AppleScript above is attempting to do, but obviously there is something more to the story.

    Bruce 55, do you have any mail you could share with me here in raw source format – from before you ran my script?

  • by Bruce 55,

    Bruce 55 Bruce 55 Apr 8, 2015 3:34 PM in response to Rich In Space
    Level 1 (4 points)
    Apr 8, 2015 3:34 PM in response to Rich In Space

    happy to privately send you  one of the affected emails - how would you like me to do this

  • by Rich In Space,

    Rich In Space Rich In Space Apr 9, 2015 6:39 AM in response to Rich In Space
    Level 1 (30 points)
    Apr 9, 2015 6:39 AM in response to Rich In Space

    Revised version of the AppleScript above (now compatible with different line endings):

     

    -----------------------------------------------------

    --Creator: Rich In Space, 7th April 2015, Revised: 9th April 2015

     

     

    tell application "Mail"

      set theMsgs to the selection

      repeat with theMsg in theMsgs

      set mID to id of theMsg

     

      if my isBadEncoding(theMsg) then

      -- if not my isBadEncoding(theMsg) then

      set theDir to POSIX path of (path to library folder from user domain) & "Mail/V2/"

      set shellScr to "mdfind -onlyin " & theDir & " 'kMDItemFSName == " & quote & mID & ".emlx" & quote & "'"

      set mPath to do shell script shellScr

      if mPath ≠ "" then my FixEnc(POSIX file mPath as string)

      end if

      end repeat

    end tell

     

     

     

     

    on isBadEncoding(theMsg)

      tell application "Mail" to set theCont to content of theMsg

      set theContSum to summarize theCont

     

      if length of theContSum ≥ 10 then

      set chars to 10

      else

      set chars to length of theContSum

      end if

      set checkSum to 0

      repeat with i from 1 to chars

      set checkSum to checkSum + (id of character i of theContSum)

      end repeat

     

      return checkSum / chars > 256

    end isBadEncoding

     

     

     

     

    on FixEnc(mPath)

      tell application "TextEdit"

      open file mPath

      set vDoc to front document

     

      set vFirstLine to paragraph 1 of vDoc

      set vLineDel to character -1 of vFirstLine

      set vLineDel2 to character -2 of vFirstLine

      if id of vLineDel2 < 32 then set vLineDel to vLineDel2 & vLineDel

     

      set EncPar to "Content-Transfer-Encoding: base64" & vLineDel

      set NHits to count (every paragraph of vDoc where it = EncPar)

      repeat NHits times

      set first paragraph of vDoc where it = EncPar to ""

      end repeat

     

      save vDoc

      close vDoc saving yes

      end tell

    end FixEnc

    -----------------------------------------------------

  • by Rich In Space,

    Rich In Space Rich In Space Apr 9, 2015 6:48 AM in response to Bruce 55
    Level 1 (30 points)
    Apr 9, 2015 6:48 AM in response to Bruce 55

    Bruce 55 wrote:

     

    happy to privately send you  one of the affected emails - how would you like me to do this

    Thanks Bruce 55, but no need this time. Another user (hr101) in the parallel thread above sent me one of his emails. After looking at it, it turned out to be just a line-ending character that I missed (+ a small bug in TextEdit). Please, use the revised AppleScript above and let me know how it worked.

  • by Bruce 55,

    Bruce 55 Bruce 55 Apr 9, 2015 4:11 PM in response to Rich In Space
    Level 1 (4 points)
    Apr 9, 2015 4:11 PM in response to Rich In Space

    Hi Rich in Space,

     

    Perfect and thank you so much - this will save me lots of time through out my day

first Previous Page 6 of 8 last Next