problem with email attachments (in xojo example files)

  1. 3 months ago

    Jean-Yves P

    Mar 12 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    Hi Folks,

    I have problems sending emails with an attachment with xojo in my program.
    So I tried the xojo examples.
    there are 2 examples in /communications/internet, one simple, and one with secure email (gmail)
    I tried both.
    I succeded sending a simple email to myself, with both example email apps.
    but when I try to send an attachment (a simple pdf lying on my desktop), the attachment arrive with 1 byte size and is of course unreadable.

    can anyone try and confirm this ?
    thanks.

    xojo 2017r3 on mac os 10.11.6

    To make it work, I had to change:

    // add attachments
    If fileFld.Text <> "" Then
      file = New EmailAttachment
      file.LoadFromFile(GetFolderItem(fileFld.Text))
      mail.Attachments.Append(file)
    End If

    to

    // add attachments
    If fileFld.Text <> "" Then
      file = New EmailAttachment
      file.LoadFromFile(GetFolderItem(fileFld.Text, FolderItem.PathTypeShell))
      file.MIMEType = "application/pdf"
      mail.Attachments.Append(file)
    End If
  2. Jean-Yves P

    Mar 12 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    found the problem in my application: problem was that my smtp provider does not accept the same sender and recipient !
    but the problem of empty attachments on xojo examples are still there.

  3. Alberto D

    Mar 12 Pre-Release Testers, Xojo Pro Answer

    To make it work, I had to change:

    // add attachments
    If fileFld.Text <> "" Then
      file = New EmailAttachment
      file.LoadFromFile(GetFolderItem(fileFld.Text))
      mail.Attachments.Append(file)
    End If

    to

    // add attachments
    If fileFld.Text <> "" Then
      file = New EmailAttachment
      file.LoadFromFile(GetFolderItem(fileFld.Text, FolderItem.PathTypeShell))
      file.MIMEType = "application/pdf"
      mail.Attachments.Append(file)
    End If
  4. Beatrix W

    Mar 12 Pre-Release Testers Europe (Germany)

    Don't use Xojo for sending mails with attachments. It's been borked for the last years.

    Curl and the Chilkat plugin work fine.

  5. Jean-Yves P

    Mar 13 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    @Beatrix W Don't use Xojo for sending mails with attachments. It's been borked for the last years.

    Curl and the Chilkat plugin work fine.

    was aware of that, but trying to be plugin free (and still ok as of today)
    thanks.

  6. Alberto D

    Mar 13 Pre-Release Testers, Xojo Pro

    The problem was with the GetFolderItem, it was trying to find a file in another folder/reference. Because it is a 'simple' example, there was no check to see if the file existed.

    I'm new to programming and Xojo, I haven't read information/bugs about not to send mails with attachments.

    I also want to be plugin free, for a newbie of for hobby is expensive to buy all the plugins recommended.

    Jean-Yves maybe you can file a bug report or contact Paul, I bet he will fix the examples for the next release.

  7. Beatrix W

    Mar 13 Pre-Release Testers Europe (Germany)

    The problem is not the sending of the file. The attachment ends up with a duplicate name. If the original name is "bla" the file ends up as "blabla" at the other end.

    Feedback Case #42655

  8. Jean-Yves P

    Mar 13 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    @Beatrix W The problem is not the sending of the file. The attachment ends up with a duplicate name. If the original name is "bla" the file ends up as "blabla" at the other end.

    Feedback Case #42655

    I did not get that problem ?

  9. Alberto D

    Mar 13 Pre-Release Testers, Xojo Pro
    Edited 3 months ago

    @Beatrix W The problem is not the sending of the file. The attachment ends up with a duplicate name. If the original name is "bla" the file ends up as "blabla" at the other end.

    Feedback Case #42655

    Thank you Beatrix for reporting that. I downloaded your files from that report and I don't get the duplicate name. Also I actually send the .txt.gz file with the Xojo example above to my account at hotmail and I get the filename just as the original file (not duplicate).

    Do you think that the Xojo team changed something with the email code and they didn't mark the case as fixed?

    ETA: I'm using macOS 10.12.6 and Xojo 2017r2.1

  10. Beatrix W

    Mar 13 Pre-Release Testers Europe (Germany)

    @Alberto D;Poo : the bug still is the same. Run the example, click the button and select the session log file. Now have a look at the value of the temp variable.

    --o5grmq67ejju
    Content-Type: application/gzip; name="Session_Log_2016-02-11_14-28-52.txt.gz"; name*=utf-8''Session_Log_2016-02-11_14-28-52.txt.gz
    x-mac-type="00000000"
    x-mac-creator="00000000"
    Content-transfer-encoding: Base64
    Content-disposition: attachment; filename="Session_Log_2016-02-11_14-28-52.txt.gz"; filename*=utf-8''Session_Log_2016-02-11_14-28-52.txt.gz

    Both Content-Type and Content-Disposition are incorrect. Where you get the filename and later the filename* you have to concatenate the values which gives you "Session_Log_2016-02-11_14-28-52.txt.gzSession_Log_2016-02-11_14-28-52.txt.gz" as result.

  11. Alberto D

    Mar 13 Pre-Release Testers, Xojo Pro

    Sorry I misunderstood the problem. I expected a file inside my email client with the name "Session_Log_2016-02-11_14-28-52.txt.gzSession_Log_2016-02-11_14-28-52.txt.gz" but I guess (at least Hotmail) that they do not concatenate the values.

    Maybe Hotmail drop one of the 'filename', this is the source Hotmail show:

    Content-Type: application/gzip; name="Session_Log_2016-02-11_14-28-52.txt.gz"; name*=utf-8''Session_Log_2016-02-11_14-28-52.txt.gz
    x-mac-type="00000000"
    x-mac-creator="00000000"
    Content-Transfer-Encoding: Base64
    Content-Disposition: attachment; filename*="utf-8''Session_Log_2016-02-11_14-28-52.txt.gz"

    I see there is no filename= and the filename*=utf-8... is now filename*="utf-8...

  12. Alberto D

    Mar 13 Pre-Release Testers, Xojo Pro

    And this is what I get (source) from Gmail:

    Content-Type: application/pdf; name="test.pdf"; name="test.pdf"x-mac-type="00000000" x-mac-creator="00000000"
    Content-transfer-encoding: Base64
    Content-disposition: attachment; filename="test.pdf"; filename="test.pdf"

    No name*=utf-8 or filename*=utf-8, but the values are duplicate.

    The filename shown on Gmail is not duplicate and when I download the file it gets saved as 'test.pdf'

    So the bug still there and I guess different email apps handle that issue in different way.

  13. Jean-Yves P

    Mar 14 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    I've just been flagged as a spam emailer by my smtp provider ... ;)
    I don't think I've sent more than 30 emails, and only 10's have actually arrived to the recipient.
    do you know the main criterias used by the smtp servers to check for a spam potential ?
    anything simple I could have missed in the content of my automated emails ?
    ( they just send a small text, with a pdf attached, to a customer)
    thanks.

  14. Beatrix W

    Mar 14 Pre-Release Testers Europe (Germany)

    Usually, it's the number of mails you send. That's the main reason you should use something like SendGrid, Mandril or similar. You can send up to 200 mails with SendGrid per day for free.

  15. Jean-Yves P

    Mar 14 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    it's strange because I can still send emails with apple Mail, but with my xojo program they are all considered as spam.
    so I definitely think it's what's inside the mail that causes problems. may be some missing header ?

  16. Albin K

    Mar 14 Europe (Sweden)

    Could be a header problem. I’ve build a system that’s sending hundreds of emails on a single day. I remember having some issues when developing this, I can take a look at my code tonight(if you haven’t figured it out by then)

  17. Alberto D

    Mar 14 Pre-Release Testers, Xojo Pro

    Are you using this from the demo?:

    mail.Headers.AppendHeader("X-Mailer","Xojo SMTP Demo")

    Somethings to check:

    • header differences between an email from apple Mail and your app
    • if you are connecting to the preferred server port (465 or 587)
    • maybe check how many mails per minute you are sending
    • if you send to a gmail account you can select 'Show Original' and will tell you if your email passed SPF and DKIM tests

    Are you using Gmail smtp server or other server?
    What server is marking your emails as spam, the smtp server or the receiving server? If it is the receiving server is one in particular, like Gmail, Hotmail, company server, or all of them?

  18. Albin K

    Mar 14 Europe (Sweden)
    Edited 3 months ago

    Make sure your emails are multipart.
    That is, they contain an HTML part and a TEXT part.
    I think there was a header too for that.. don’t have my code here right now..

    Some filters do block emails that only contain simple TEXT.

    I recommend MailJet as SMTP.

  19. Jean-Yves P

    Mar 14 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    @Albin K Make sure your emails are multipart.
    That is, they contain an HTML part and a TEXT part.

    it was working when there was only a simple text and a pdf attachment.
    yesterday I added an RTF text, but no HTML, and I got stopped by the smtp server (my provider)
    I removed the RTF part and it's still blocked.
    there is no HTML part in the mail. should I add one ?

  20. Jean-Yves P

    Mar 14 Pre-Release Testers, Xojo Pro Europe (France, Besancon)

    @Alberto D;Poo maybe check how many mails per minute you are sending

    one to 3 in a minute, then I stop as it is a manual operation now.

  21. Newer ›

or Sign Up to reply!