XML file attached in Gmail appears open in message body

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
User avatar
PedroAlex
Posts: 229
Joined: Tue Feb 09, 2010 3:06 am

XML file attached in Gmail appears open in message body

#1 Post by PedroAlex »

Hi, guys,

I have a problem that I don't see the reason for.

If I send an XML file as an attachment through a program written in xbase, the recipient receives the entire file open in the body of the email message and not as an attachment.

But if I send the same XML file as an attachment through Chrome/Gmail, the recipient correctly receives the file only as an attachment.

This only happens if the sending account is gmail. if I use another email from another service, this does not happen.

Does anyone know why this strange behavior occurs in gmail emails sent by xbase?
Has anyone had this problem?

Many Thanks?
Pedro Alexandre

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: XML file attached in Gmail appears open in message body

#2 Post by rdonnay »

Try changing the content-type.

oMail:setContentType('multipart/form-data')
The eXpress train is coming - and it has more cars.

User avatar
PedroAlex
Posts: 229
Joined: Tue Feb 09, 2010 3:06 am

Re: XML file attached in Gmail appears open in message body

#3 Post by PedroAlex »

Roger,
I tried your suggestion but got the same result.
Does this happen with you too?
Pedro Alexandre

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: XML file attached in Gmail appears open in message body

#4 Post by skiman »

Hi Pedro,

I never noticed this problem when sending.

How is the attachment added? As a file?

I'm using Chilkat for sending mails, There is an oEmail:AddFileAttachment( cFile) to use.
With CDO it is something similar as oCdoMessage:AddAttachment(cFile).

I suppose there can be a difference as with images, they can be an atttachment, and they can be part of the mail. Maybe this is the same for your problem and the XML?
Best regards,

Chris.
www.aboservice.be

User avatar
PedroAlex
Posts: 229
Joined: Tue Feb 09, 2010 3:06 am

Re: XML file attached in Gmail appears open in message body

#5 Post by PedroAlex »

Hi Chris,

here is sample code :

Code: Select all

//----------------------------------------------------------------------------------
Procedure SendMail_SMTP()
//----------------------------------------------------------------------------------
LOCAL oSmtp       := SMTPClient():new(  "smtp.gmail.com",465)
LOCAL oSender     := MailAddress():new( "fromemailadress@gmail.com" )
LOCAL oRecipient  := MailAddress():new( "toemailadress@gmail.com" )
LOCAL cAttachment := 'C:\File.xml'
LOCAL oMail       := MIMEMessage():new()
LOCAL cText       := "Anexed, file XML" 

//oMail:setContentType('multipart/form-data')
oMail:setContentType('application/xml')
oMail:setFrom     ( oSender     )
oMail:setSubject  ( "XML File attached" )
oMail:setMessage  ( cText       )
oMail:addRecipient( oRecipient  )
oMail:attachFile  ( cAttachment )

      IF oSmtp:connect( "fromemailadress@gmail.com", "cKeyApp" )

         IF oSmtp:send( oMail )
            MsgBox( "Message sent" )
         ELSE
            MsgBox( "Unable to deliver message" )
         ENDIF

         oSmtp:disconnect()

      ELSE

         MsgBox(  "Unable to connect to mail server" )

      ENDIF

   RETURN

Pedro Alexandre

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: XML file attached in Gmail appears open in message body

#6 Post by skiman »

Hi,

Why are you doing this?

Code: Select all

oMail:setContentType('application/xml')
Have you tried it without this setting?
Best regards,

Chris.
www.aboservice.be

User avatar
PedroAlex
Posts: 229
Joined: Tue Feb 09, 2010 3:06 am

Re: XML file attached in Gmail appears open in message body

#7 Post by PedroAlex »

Hi Chris,
Yes, I've tried other settings and it's the same.
Can you try with this code?
The problem only happens when the recipient opens gmail in the browser, eg. in Chrome.
I've already tested it with Chilkat and this problem doesn't happen.
Pedro Alexandre

skiman
Posts: 1183
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: XML file attached in Gmail appears open in message body

#8 Post by skiman »

Hi Pedro,

I'm using Chilkat, and because I don't have to set any contenttype, I was wondering if that could be the cause.

I never had a customer who had this complaint. Electronic invoices are send as XML, so if this would be a problem, customers would have reported this.

Any reason you don't use Chilkat? Since it looks you have it?
Best regards,

Chris.
www.aboservice.be

User avatar
PedroAlex
Posts: 229
Joined: Tue Feb 09, 2010 3:06 am

Re: XML file attached in Gmail appears open in message body

#9 Post by PedroAlex »

Hi Chris,

This strange behavior does not stop the system from working. The XML file is sent as an attachment. It simply appears all open in the body of the email and only at the end of all this text is the link to download.
However, I repeat this situation only if the email received is consulted in gmail online.
If the received email is consulted for example in windows mail everything is OK.
I don't have Chilkat, I've been testing the 30 day version.
I always give preference to developing the needs in native xBase++ or with eXpress++.
But developing in xBase++ is getting difficult and expensive.
Chilkat is an excellent library and it seems to me that sooner or later I will have to buy it, because there are needs that xBase doesn't answer.
However I noticed that sending the email with xBase is much faster than sending it with Chilkat. with Chilkat it is necessary to establish a connection with the Activex component and perhaps this procedure will remove some application performance.
Pedro Alexandre

Post Reply