# Mime Attachment Problem

**URL:** <https://forum.xojo.com/t/mime-attachment-problem/30516>\
**Category:** General\
**Created:** [March 27, 2016, 6:20pm UTC](https://forum.xojo.com/t/mime-attachment-problem/30516 "2016-03-27T18:20:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ELVIS\_AGAMEZ](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ELVIS\_AGAMEZ](https://forum.xojo.com/u/ELVIS_AGAMEZ)\
**Post date:** [March 27, 2016, 6:20pm UTC](https://forum.xojo.com/t/mime-attachment-problem/30516/1 "2016-03-27T18:20:00Z")

</div>

Hi All,

I have created a class to send a mail with two attached images (.jpg). The proccess works fine, but when the user receive the information, he can see the images in PC and laptop without problems, but not in tablets and mobiles.

In tables and mobiles, the images are being shown with the name: “mime-attachment” but is not possible show the image. I’m not sure if my code for header is correct, I’ll appreciate any suggestion to clarify the code or improve it. I can not find what I doing bad.

```auto

  'Customizing mail parameters
  Mail = New EmailMessage
  Mail.fromAddress=sFromAddress
  Mail.subject= sSubject
  Mail.bodyPlainText = sTextMessage
  [b]Mail.headers.SetHeader "Content-Type","image/jpeg"
  Mail.headers.appendHeader "MIME-Version","1.0"
  Mail.headers.appendHeader "X-Mailer","Email"[/b]
  Mail.addRecipient(sToAddress)

  'Customizing attachment files
  If sAttachFileA<>"" Then
    File = New EmailAttachment
    File.loadFromFile GetFolderItem(sAttachFileA)
    Mail.attachments.append File
  End If
  
  If sAttachFileB<>"" Then
    File = New EmailAttachment
    File.loadFromFile GetFolderItem(sAttachFileB)
    Mail.attachments.append File
  End If
  
  'Send mail
  Self.Messages.Append mail
  Self.SendMail

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Beatrix\_Willius](https://forum.xojo.com/user_avatar/forum.xojo.com/beatrix_willius/32/282_2.png) [@Beatrix\_Willius](https://forum.xojo.com/u/Beatrix_Willius)\
**Post date:** [March 28, 2016, 3:06am UTC](https://forum.xojo.com/t/mime-attachment-problem/30516/2 "2016-03-28T03:06:05Z")

</div>

The only problem I see in your code is this here:

```auto
Mail.headers.SetHeader "Content-Type","image/jpeg"
```

This doesn’t make sense. You could try with a non-plain message body. Recently there was a discussion about attachment names messed up. They have a duplicate names like “filename.txtfilename.txt”: \<[https://xojo.com/issue/42655](https://xojo.com/issue/42655)\> . Directly manipulating the source doesn’t work. Therefore some users switched to using CURLMBS.

---

<div class="post-metadata">

**Author:** ![ELVIS\_AGAMEZ](https://forum.xojo.com/letter_avatar_proxy/v4/letter/e/97f17d/32.png) [@ELVIS\_AGAMEZ](https://forum.xojo.com/u/ELVIS_AGAMEZ)\
**Post date:** [March 28, 2016, 5:23pm UTC](https://forum.xojo.com/t/mime-attachment-problem/30516/3 "2016-03-28T17:23:11Z")

</div>

Hi Beatrix,

Thanks for your replay. I forgot mention in my previous mail that the problem of visualization is presented in tables and mobiles just for iPad and iPhone, in others devices, the attached images can be visualized properly.

I think that Apple has some restriction for headers with .jpg images, but I’m not sure what would be the correct code in the header to show properly these images with iPad/iPhone.

I have changed the code, but problem persist.  
[i]`

Mail.headers.appendHeader “X-Mailer”,“Email”  
Mail.Headers.AppendHeader(“Mime-Version”, “1.0”)  
Mail.Headers.AppendHeader(“Content-Type”, “text/plain; charset=utf-8”)  
Mail.Headers.AppendHeader(“Content-Transfer-Encoding”, “base64”)

Mail.fromAddress=sFromAddress  
Mail.subject= sSubject  
Mail.bodyPlainText = sTextMessage  
Mail.addRecipient(sToAddress)

'Customizing attachment files  
If sAttachFileA\<\>"" Then  
File = New EmailAttachment  
File.MIMEType=“image/jpeg”  
File.MIMEType=“image/jpg”  
File.loadFromFile GetFolderItem(sAttachFileA)  
Mail.attachments.append File  
End If

If sAttachFileB\<\>"" Then  
File = New EmailAttachment  
File.MIMEType=“image/jpeg”  
File.MIMEType=“image/jpg”  
File.loadFromFile GetFolderItem(sAttachFileB)  
Mail.attachments.append File  
End If[/i]

`

I’ll check your thread, perhaps I can find some solution.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [March 29, 2016, 11:36am UTC](https://forum.xojo.com/t/mime-attachment-problem/30516/4 "2016-03-29T11:36:48Z")

</div>

You can only set the mime type once per attachment. Also, while you are specifying base64 in the headers, you’re not inserting base64 data. Try leaving off all of the headers except your x-mailer header and see if that works.

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:14pm UTC](https://forum.xojo.com/t/mime-attachment-problem/30516/5 "2020-10-29T18:14:39Z")

</div>


