locked
Outlook 2016 - Missing JPEG image attachment in emails received from Swann NVR system RRS feed

  • Question

  • I have a Swann NVR CCTV system which sends motion detection emails to my Gmail email address.  Outlook 2016 (version 16.0.8326.2076, 32-bit) is configured to download the emails from Gmail's POP3 server.  Every email should contain one JPEG image attachment of the captured motion, however in Outlook 2016 the image is missing for 66% (2 out of 3) of the emails.

    If I view the emails in the Gmail webmail via a browser, every email contains an image attachment and the image is visible.  This proves that the Swann system is correctly generating the emails and Gmail is able to decode the image in every email.

    I have enabled full image headers in Outlook (registry value HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Options\Mail\SaveAllMIMENotJustHeaders = 1).  When I view the email headers of an email with an apparently missing image, the entire base64-encoded image is present in the email, as shown by this truncated example:

    Content-Type: multipart/mixed; boundary=-----part1-----

    -------part1-----
    Content-Type: text/plain; charset=ISO-8859-1

    Alarm Camera Name:Camera4
    Alarm Event:Motion Detection

    Alarm Input Channel No.:4
    Alarm Device Name:NVR


    -------part1-----
    Content-Type: image/jpeg; name="04_20170912161145.jpg"
    Content-Dis; filename="04_20170912161145.jpg"
    Content-Transfer-Encoding: base64

    /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf
    IiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7
    <truncated>

    +YliKa6nSWvirTba+N8beYzTmMyr5S/utgxlG3ZJOO4GM1i67ri6xa2ZcStcwqyyySncWHGPm6no
    evrWe9tkjZIrbhlT2I9sZ74596VtNkOAJVHPOBnj/HpS+tUf5vzLVeEtE/6/r/JH/9k=-------part1-----

    I can copy and paste all the base64 characters (from /9j/4AA to /JH/9k=) to https://codebeautify.org/base64-to-image-converter and a correct image is generated.

    I have downloaded the .jpg image file attachments from Gmail and found that Outlook displays the image in the email only if the .jpg file size is exactly divisible 3.  This means that Outlook doesn't display the image for 2 out of 3 emails (66%).  Related to this, I have found that the image is missing from Outlook if the base64 encoding ends with "=" or "==", which I think are characters to pad the base64 encoding to a certain length.  You can see a single "=" padding character as the last character in the above example.

    The motion detection emails are also sent to Outlook 2010 and Outlook 2007 email clients and the image attachment is present in all emails, so for me the problem only occurs with Outlook 2016.  In summary, Outlook 2016 is unable to decode 66% of the email image attachments.

    Thanks for any help.

    Monday, September 18, 2017 1:22 PM

All replies

  • Hi JWE111,

    Thanks for posting with the detailed information.

    >>I  have downloaded the .jpg image file attachments from Gmail and found that Outlook displays the image in the email only if the .jpg file size is exactly divisible 3. 

    Could you please clarify what you mean by "the .jpg file size is exactly divisible 3"? 
    I tried to test with a .jpg file (37.2KB), the attachment can be received as expected in my Outlook 2016. Did I miss anything? If possible, you may share a problematic picture via OneDrive and paste a link here then I can see if the issue can be reproduced in our environment.

    By the way, does the problem only occur to JPEG file? How about other types of images?
    Does this issue affect other types of email accounts?

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Tuesday, September 19, 2017 9:44 AM
  • Hi Yuki Sun,

    Thank you for replying.

        >> Could you please clarify what you mean by "the .jpg file size is exactly divisible 3"?

    Sorry, I omitted the word 'by' in that sentence.  It should say "the .jpg file size is exactly divisible by 3".

    I downloaded the .jpg files for 7 motion detection emails from Gmail's webmail and the following table shows their file size, the file size divided by 3 and whether or not the image is shown in the Outlook email:

        .jpg file size in bytes; Size divided by 3; Is size exactly divisible by 3?; Result in Outlook
        21,602;  7,200.66;  No; Image missing in Outlook email
        21,580;  7,193.33;  No; Image missing in Outlook email
        20,463;  6,821.00; Yes; Image shown in Outlook email
        30,153; 10,051.00; Yes; Image shown in Outlook email
        30,791; 10,263.66;  No; Image missing in Outlook email
        29,982;  6,994.00; Yes; Image shown in Outlook email
        30,928; 10,309.33;  No; Image missing in Outlook email

        >>I tried to test with a .jpg file (37.2KB), the attachment can be received as expected in my Outlook 2016. Did I miss anything? If possible, you may share a problematic picture via OneDrive and paste a link here then I can see if the issue can be reproduced in our environment.

    Receiving a .jpg file attachment, per se, is not the problem.  The problem only occurs with the .jpg files received from the Swann NVR system, and 2 out of 3 of these emails have missing images.

    Here is a link for you to download a .jpg file image which is missing from the email received by Outlook:

    https://drive.google.com/open?id=0B26jC_48aIHdSTNtQnlWazNIQzA

        >> By the way, does the problem only occur to JPEG file? How about other types of images?
        Does this issue affect other types of email accounts?

    Yes, the problem only occurs with JPEG files, and only with the JPEG file attachment in the emails sent by the Swann NVR system.  JPEG is the only type of image sent by the Swann NVR system.  My Outlook correctly displays images (JPEG, PNG, GIF, etc) which are sent manually in emails.

    I think Outlook 2016's base64 decoder has a bug in decoding the last line of a Base64 attachment whose size is not a multiple of 3 bytes (so one or two '=' padding characters are added).

    I hope you can help further with this problem.

    Thanks,


    • Edited by JWE111 Tuesday, September 19, 2017 12:52 PM
    Tuesday, September 19, 2017 11:56 AM
  • Hi JWE111,

    Thanks for the update.

    I downloaded the sample JPEG file you shared above and tried to send and receive using email account configured in Outlook 2016. The image can show properly as an attachment. 

    Regarding your concern about "The problem only occurs with the .jpg files received from the Swann NVR system", sorry but we do not have a Swann NVR system to help test further. If possible, could you please try testing with another email client and see if the issue persists? It is also encouraged to contact the Swann NVR system support community and see if other users have seen the similar situation.

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Friday, September 22, 2017 2:03 AM
  • Hi,

    Thank you for your continuing help.

    I have contacted Swann support.  They point out that because the image attachment is always present and can be viewed in the Gmail webmail, for both the sender email address and the recipient email address, this proves that their system is correctly generating and sending the email.

    Furthermore, as I said in my OP, the Swann NVR system is sending the emails at the same time to email clients running Outlook 2007, Outlook 2010 and Outlook 2016.  The image attachment is always present and visible in every email received by the Outlook 2007 and 2010 clients.  The image attachment is also always present and visible when received by an Outlook Express client.  It is only Outlook 2016 where the image attachment is missing in 2 out of 3 emails, on average.

    I have changed the Swann NVR system so that it sends the emails via my internet service provider's SMTP server, instead of Gmail's SMTP server (smtp.gmail.com).  This made no difference; exactly the same scenerio exists: the image attachment is always present and visible in every email received by Outlook 2007, Outlook 2010 and Outlook Express, but missing in 2 out of 3 emails, on average, received by Outlook 2016.

    The '2 out of 3' average is significant due to the fact that the Base64-encoded image attachment can contain 0, 1 or 2 '=' padding characters to ensure that the total number of characters is a multiple of 3.  If 1 or 2 '=' padding characters are added then Outlook 2016 is unable to decode the characters into a visible image or attachment.

    The image bytes are present as Base64-encoded characters in the email headers, however Outlook 2016 is unable to decode them into a visible image or attachment.

    All this points to a bug in Outlook 2016.

    Is possible for you to escalate this issue to Microsoft, please?

    Thanks,

    PS - My problem is similar to that described by P.V.Geens reply at the top of page 2 of this thread:

    https://answers.microsoft.com/en-us/office/forum/office_2010-outlook/outlook-2010-decodes-pdf-attachment-as-all-zero/51012fe5-9d5e-431d-9d9c-a37b0171264a?page=2&auth=1


    • Edited by JWE111 Friday, September 22, 2017 12:19 PM
    Friday, September 22, 2017 12:02 PM
  • Hi JWE111,

    Thanks for your feedback. 

    As "Outlook correctly displays images (JPEG, PNG, GIF, etc) which are sent manually in emails.", it seems to me that Outlook 2016 is able to decode them into visible images. 

    Since the image can display as expected in webmail, could you please try to login to webmail and forward a problematic attachment to both yourself and GBSD TN Office Information Collection ibsofc@microsoft.com? I would open the file in our test environment and see if the attachment can be seen. Please involve the thread URL in the email message for easy follow-up :)

    Besides, how about sending the images from Swann NVR system to other types of accounts (IMAP or Exchange)?

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Tuesday, September 26, 2017 9:50 AM
  • Hi,

    Thank you very much for your continued help.

    A recent Office update has updated my Outlook to version 16.0.8431.2046 and the problem persists.

    I don't think that forwarding a problematic email to you will illustrate or allow you to reproduce the problem because the webmail (Gmail) will correctly package the whole email (email body and image attachment).  Nevertheless, I have forwarded both a good email (attachment present when delivered to Outlook) and a problematic email (attachment missing when delivered to Outlook) from Gmail to myself and ibsofc@microsoft.com.

    The best way for you to see the problem is for me to configure my Swann NVR device to send the motion detection emails to your email address.  Please let me know if you want me to do this.

    I have noticed something with the email headers, specifically the boundary string, created by the Swann firmware.  The boundary string is always "-----part1-----", without the quotes.  This boundary string is used to separate different parts of the email as follows:

    Content-Type: multipart/mixed; boundary=-----part1-----

    -------part1-----
    Content-Type: text/plain; charset=ISO-8859-1

    Alarm Camera Name:Camera4
    Alarm Event:Motion Detection

    Alarm Input Channel No.:4
    Alarm Device Name:NVR16-7300


    -------part1-----
    Content-Type: image/jpeg; name="04_20170927102352.jpg"
    Content-Dis; filename="04_20170927102352.jpg"
    Content-Transfer-Encoding: base64

    /9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIf
    IiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7
    < Base64 image characters truncated >
    cqk/qTx17GrduDbJtOZGY/M/Sj6zRva4fWqXf8zr7fxDZQXZu2ilMsxjMi+Wv7vaMfK27nP0HWsn
    V9WGpW1qW8xp4lYSPIdxYcY56nv+dY0lyTt2KrbhlTu6/TGe+PzpTvOBtU888np/j0pfWqP835lR
    xFKTsn/X9fef/9k=-------part1-----

    I have written programs which do multipart email construction and therefore know something about how the boundary string should be used.  The answer at https://stackoverflow.com/a/4656646 shows how the boundary should be used in every part of the email.  The important sentence is: "The preceding -- is mandatory for every boundary used in the message and the trailing -- is mandatory for the closing boundary (close-delimiter)."

    In the above headers, the following part of the message is correct because the boundary "-----part1-----" is preceded by "--":

    -------part1-----
    Content-Type: text/plain; charset=ISO-8859-1

    Similarly, the following part of the message is also correct because the boundary "-----part1-----" is preceded by "--":

    -------part1-----
    Content-Type: image/jpeg; name="04_20170927102352.jpg"

    However, the following part of the message is incorrect because the closing boundary is preceded by "--", but not trailed by "--".

    xFKTsn/X9fef/9k=-------part1-----

    Maybe Outlook 2016 is stricter than Outlook 2007 and Outlook 2010 about following the rules for the boundary string and is confused when it sees the "=" or "==" padding characters. Remember, exactly the same correct and incorrect boundary strings are used in every email.  It is only when the padding character(s) are not needed that Outlook 2016 is able to decode the Base64 characters into an image.

    I don't want to use IMAP because I much prefer POP3 for my setup, using it satisfactorily for many years.  I have configured Gmail to keep a copy of emails, so POP3 with Gmail gives automatic backup of emails: emails are downloaded to Outlook's .pst file and kept on Gmail's webserver.  Emails that I delete in Outlook are still available in Gmail.  My understanding of IMAP is that it synchronises folders between Outlook and Gmail and therefore emails deleted from Outlook are also deleted from Gmail, and vice versa, losing the backup facility that POP3 can provide.

    Sorry, but I don't have an Exchange server to connect to.

    Thanks,

    Wednesday, September 27, 2017 11:39 AM
  • As "Outlook correctly displays images (JPEG, PNG, GIF, etc) which are sent manually in emails.", it seems to me that Outlook 2016 is able to decode them into visible images.

    Just to address the above point, and emphasise what I've already posted, above and below this reply.

    Yes, Outlook 2016 can correctly decode manually sent images.  No problem at all with that.

    But the images are not being sent manually; they are being sent by the Swann NVR device firmware.  And Outlook 2016 is unable to decode the image in 2 out of 3 emails on average, even though all the Base64 characters representing the image are present in the email headers.

    The emails are sent by the Swann NVR device to Outlook 2007, 2010 and 2016 clients at the same time (up to 3 recipients can be defined).  Outlook 2007 and 2010 both correctly decode and display the image in every email sent by the Swann NVR.  It is only Outlook 2016 that cannot decode and display 2 out of 3 emails on average.

    Therefore I conclude that the decoding of the email headers and/or Base64-encoded image is different, or stricter regarding the boundary string described in my post after this one, in Outlook 2016.

    I hope that helps your understanding of this problem.

    Thanks again.



    • Edited by JWE111 Wednesday, September 27, 2017 7:32 PM
    Wednesday, September 27, 2017 7:30 PM
  • Hi JWE111,

    Thanks for the detailed clarification.

    I checked the messages you forwared and both of the two JPEG images can be seen as expected. If it is convienient for you, could you please configure the Swann NVR device to send a few motion detection emails (contain at least a problematic one) to our GBSD TN Office Information Collectionibsofc@microsoft.com

    I would like to check the messages on different versions of Outlook and see if the issue can be reproduced in our environment.

    Best regards,
    Yuki Sun



    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Saturday, September 30, 2017 12:46 PM
  • Hi,

    OK, I will configure the Swann email settings to send to your email address, however I won't be able to do this until 10th October.

    Please make sure you have configured Outlook to save full message headers.

    Thanks,

    Sunday, October 1, 2017 9:38 AM
  • Hi,

    As promised, today (10 October 2017) I have configured the Swann NVR system to send the motion detection emails to my email address (an Outlook 2016 client) and your email address, ibsofc@microsoft.com.

    The Swann NVR system first sent a test email with the subject "Test e-email" and message body "If you receive this e-mail you have successfully setup and tested the e-mail alert from your NVR", which you should have received at approximately 16:29 UTC.  This email is simply a text message and doesn't contain the image attachment.

    The 1st motion detection email (the subject is always "Motion Detection") was sent at approximately 16:37 UTC (its received time in my Outlook is 16:37 UTC).  This email, when viewed in Outlook 2016, does not contain the image attachment, even though the Base64-encoded characters for the image are present in the full MIME text, so is an exact example of the problem described in this thread.

    The 2nd motion detection email was received by my Outlook at 16:43 UTC.  This email also doesn't contain the image attachment.

    The 3rd motion detection email was received by my Outlook at 17:22 UTC.  This email does contain the image attachment and it can be viewed in Outlook.

    The 4th motion detection email was received by my Outlook at 17:30 UTC.  This email does contain the image attachment and it can be viewed in Outlook.

    Therefore the system has sent 4 motion detection emails to your email address: 2 are missing the image attachment and 2 contain the viewable image attachment.

    I hope that this is enough data for you to investigate this problem further.

    Thanks,

    Tuesday, October 10, 2017 5:44 PM
  • Hi JWE111,

    I received all the 5 messages you mentioned (1 "Test e-mail" and 4 "Motion Detection") without missing any one of the image attachments:

    I have checked the mailbox in several different versions of Outlook (16.0.8201.2198, 16.0.8528.2074 and 16.0.8625.2032), the 4 attachments can be seen on all of them.

    Have you tested on another computer with Outlook 2016 and check the result? 

    It is also suggested to try to add other types of accounts side by side with the gmail account, then try sending the motion detection emails to all the accounts and check if the attachments can be received.

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Wednesday, October 11, 2017 2:03 AM
  • Hi Yuki Sun,

    Thank you for checking the emails, and it is interesting that none are missing the attachment.  Are your different Outlook versions downloading them using POP3 or IMAP?

    Yes, I have tested on another computer with Outlook 2016 (16.0.8431.2046) 32-bit and the same problem occurs.  The emails were sent to an email address for my ISP, so not a Gmail account.

    As mentioned in my message dated Friday, September 22, 2017 12:02 PM, I have also tried sending to the SMTP server of my ISP instead of smtp.gmail.com and the same problem occurs.

    Thanks for your continuing help.

    cheers,

    Wednesday, October 11, 2017 4:07 PM
  • Hi Yuki Sun,

    An Office update yesterday has updated my Outlook to version 16.0.8528.2126, but the problem still occurs.

    Are your different Outlook versions downloading the emails using POP3?  If not, then your environment is not the same as mine and your tests can't really reproduce the problem.

    Please confirm this.

    Thanks,

    Wednesday, October 18, 2017 11:07 PM
  • Hi Yuki Sun,

    It's been 3 weeks since I first asked and I've not heard from you.  Please would you answer my simple question.

    Did your tests use POP3?

    Thanks,

    Tuesday, October 31, 2017 12:40 PM
  • Hi JWE111,

    Sorry for keeping you waiting.

    The mailbox we mentioned above is a public folder added to the exchange account. 

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Tuesday, October 31, 2017 2:09 PM
  • Hi Yuki Sun,

    Thank you for your efforts, however using an Exchange account means your environment is not the same as mine, and therefore your test could not reproduce the problem.  My Outlook is downloading the emails from a POP3 mail server - pop.gmail.com or my ISP's POP3 server.

    I'm not sure where to go from here.

    Thanks,

    Monday, November 13, 2017 11:49 PM
  • Did you ever find a fix for this?

    One of our users (Exchange 2013, Outlook 2016) received an email, in Outlook it does not display the images or show there is an attachment (but you can see the email size is 2MB so you know the attachments are there).

    From the same account, opening the same email on the users phone, you can see the images.

    These are just photos in the .JPEG format.

    I guess it has something to do with Outlook not liking the .JPEG extension, as .JPG works OK.

    We can't control what our customers send to us, so we need to be able to get Outlook to work with .JPEG.

    I had the user forward the email to me, and I have the exact same issue.

    Any ideas?

    Thursday, May 17, 2018 2:09 PM
  • I had this exact same problem from .net app sending .jpg files

    The issue existed for me on the latest versions of Outlook 2016, 2019 and outlook 365, all using Microsoft exchange 365.

    Outlook desktop app simply do not show the .jpg attachment.  You can however see the paperclip icon that shows there is an attachment, there was just no way to open it.

    I fixed it by changing the code in the sending app:

    Dim sBodyLen As Integer = Int(sBody.Length)

    oAttach = oAttachs.Add(sFilename, , sBodyLen, sDisplayname)

    to:

    oAttach = oAttachs.Add(sFilename, Outlook.OlAttachmentType.olByValue, 1, sDisplayname)

    • Edited by greenlion3 Sunday, February 3, 2019 2:31 PM
    Sunday, February 3, 2019 2:10 PM