Login  
Search All Forums
Dart Home | PowerTCP Mail for ActiveX | Custom Development Reply | PowerTCP Mail for ActiveX Topics | Forums   
AuthorForum: PowerTCP Mail for ActiveX
Topic: Canīt send HTML Mail with attachments
HeikoFuchs

From: Hamburg, USA
Posts: 2
Member Since: 05/05/03
posted May 5, 2003 9:08 AM

I am trying to send HTML E-Mails with an attachment. Without any attachment the code listed below works fine:

 Smtp.To.Clear
 Smtp.To.Add Receiver
 Smtp.From = Sender
 Smtp.Message.Content = ""
 Smtp.Message.To.Clear
 Smtp.Message.To.Add Receiver
 Smtp.Message.From = Sender
 Smtp.Message.Subject = Subject
 
 'HTML BODY
 Set p = New Part
 p.Data = Body
 p.Header.Clear
 p.Header.Add msgContentType, "text/html; charset=""iso-8859-1"""
 p.Header.Add msgEncoding, "quoted-printable"
 Smtp.Message.Parts.Add p

 'TEXT BODY
 Set p = New Part
 p.Data = TXTBODY
 p.Header.Clear
 p.Header.Add msgContentType, "text/plain"
 Smtp.Message.Parts.Add p
 Smtp.Message.Header.Add msgContentType, "multipart/alternative"
  
 Smtp.Login MailServer
 Smtp.Send
 Smtp.Logout

Ok, now trying to add an attachment I Put in the code before the line "smtp.login" the following:
 Smtp.Message.AddAttachment Filename

The file will be attached and sent, but my HTML bodytext wonīt we displayed at the receiver end. Can anybody help me?

Many thanks
Heiko
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted May 6, 2003 9:18 AM

Hi Heiko,
It is probably because you have created a multipart/alternative message, and the email client considers the attachment as an alternative.

Instead, create a multipart/mixed message, with the following structure:

Multipart/Mixed Message
  1. Multipart/Alternative part
    1a. Text part
    1b. Html part
  2. Attachment

That should give you the message you are looking for.
Hope it helps,
-ken
HeikoFuchs

From: Hamburg, USA
Posts: 2
Member Since: 05/05/03
posted May 6, 2003 10:49 AM

Hi Ken!

Many, many thanks... It works perfect with this little change from you ;)

Heiko
avandam

From: London, United Kingdom
Posts: 21
Member Since: 08/23/01
posted June 3, 2003 12:34 PM

Hi Ken,

We have just experienced the same problem and have followed your advice with some success. Now all the clients we test with that support HTML now show the attachments. However, now we are finding that a client that cannot deal with html email is not showing the plain text version. Instead it is showing the whole of the Multipart/Alternative part (that contains sub-parts of the plain text and html) including the part header.

Any ideas why this may be. Is it that some email clients cannot deal with parts with sub-parts?

Thanks
Aaron
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted June 4, 2003 8:48 AM

Hi Aaron,
It sounds like that is the case with this particular client. All you can do is construct a properly formatted, conventional message - you do not have control over how the email viewer presents the parts once it has received the message. 
The alternative header means the viewer should display only one of the subparts contained within.
-ken
jhmallot
jhmallot@md2i.fr

From: chavagnes en paillers, France
Posts: 2
Member Since: 06/22/11
posted September 6, 2017 5:52 AM

HI, have you an exemple in VC6 please ?
Reply | PowerTCP Mail for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX