problem with email attachments (in xojo example files)

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

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.

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

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

Curl and the Chilkat plugin work fine.

[quote=377473:@Beatrix Willius]Don’t use Xojo for sending mails with attachments. It’s been borked for the last years.

Curl and the Chilkat plugin work fine.[/quote]
was aware of that, but trying to be plugin free (and still ok as of today)
thanks.

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.

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.

<https://xojo.com/issue/42655>

[quote=377502:@Beatrix Willius]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.

<https://xojo.com/issue/42655>[/quote]
I did not get that problem ?

[quote=377502:@Beatrix Willius]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.

<https://xojo.com/issue/42655>[/quote]

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

@Alberto De 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.

[quote]–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[/quote]

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.

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:

[quote]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"[/quote]

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

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

[quote]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”[/quote]

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.

I’ve just been flagged as a spam emailer by my smtp provider … :wink:
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.

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.

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 ?

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)

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?

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.

[quote=377637:@Albin Kiland]Make sure your emails are multipart.
That is, they contain an HTML part and a TEXT part.
[/quote]
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 ?

[quote=377636:@Alberto De Poo]maybe check how many mails per minute you are sending
[/quote]
one to 3 in a minute, then I stop as it is a manual operation now.