FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour TMail with html body and attachment
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
TMail with html body and attachment
Posted: Wed Jul 04, 2007 12:58 PM
hi everyone,

I´m using a TMail class to send mails, it´s work fine, but i have one question:

when i want send email with html body i do this:

cSubject = "Testing Html Body"

cNoteText = nil

cMsgType = nil

cConversationID = nil

dDate = Date()

cTime = Time()

lReceipt = .F.

lFromUser = .T.

aOrigin = {mymail@mymail.com}

aRecipients = {yourmail@yourmail.com}

aFiles = {{"c:\MyDocuments\MyHtml.htm","MyHtml.htm"}}

oMail:=TMail():New(cSubject ,;
                             cNoteText ,;
                             cMsgType ,;
                             cConversationID ,;
                             dDate,;
                             cTime,;
                             lReceipt,;
                             lFromUser,;
                             aOrigin,;
                             aRecipients,;
                             aFiles)


it´s works great... :-)

but if i need attach other file (a pdf file, for example), the html body is not created, and the mail has now 2 attach files, a html file and a pdf file...
:-)

aFiles = {{"c:\MyDocuments\MyHtml.htm","MyHtml.htm"},{"c:\MyDocuments\MyPdf.pdf","MyPdf.pdf"}}


i need an email with a html body and other file attached...

Many thanks :-)
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
TMail with html body and attachment
Posted: Fri Jul 06, 2007 01:48 PM

nothing ????

Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
TMail with html body and attachment
Posted: Fri Jul 06, 2007 02:35 PM
yury wrote:nothing ????


Yuri,

you must understand that emails with a html body are normal emails where the email text is formatted via html tags.

The fact that you see a html body is depending on your email client program. This has nothing to do with any attachment.

Some email clients show you attachments as if they belong to the body in case it's a jpg-picture or if it's a html file.
But this is dangerous and not standard.

So if you want to send an email with html appearance you have to format your normal body text with the necessary html tags.
As attachments you may whatever you want.

I hope my explanation was not to complicated.
If yes, ask me again.

Regards,
Detlef
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
TMail with html body and attachment
Posted: Fri Jul 06, 2007 05:20 PM

Hi Detlef,

thank you for explanation, very usefull...

do you have any example about message text formated with html tags what works with MS OutLook Express (TMail class invoke OE) ?

best regards and thank you again

Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Posts: 312
Joined: Sat Oct 08, 2005 09:12 AM
TMail with html body and attachment
Posted: Fri Jul 06, 2007 06:59 PM
Hi Yuri,

i don't have Outlook.
But you should use something like the following example:
LOCAL cMessage := "<HTML>"                                                                   + CRLF +;
                  "<HEAD>"                                                                   + CRLF +;
                  '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">' + CRLF +;
                  "</HEAD>"                                                                  + CRLF +;
                  "<BODY>"                                                                   + CRLF +;
                  "<p>Here a paragraph</p>"                                                  + CRLF +;
                  "<p>"                                                                      + CRLF +;                 
                  '  <table border="1" cellpadding="2" cellspacing="2">'                     + CRLF +;
                  "    <tr>"                                                                 + CRLF +;
                  "      <th>Val</th>"                                                       + CRLF +;
                  "      <th>Val * 100</th>"                                                 + CRLF +;
                  "    </tr>"                                                                + CRLF 

            for n := 1 to 12
               cMessage += "    <tr>" + CRLF +;
                           "      <td> " + str( n      , 2, 0 ) + "</td>"+ CRLF +;
                           "      <td> " + str( n * 100, 4, 0 ) + "</td>"+ CRLF +;
                           "    </tr>"                                   + CRLF
            next

            cMessage += "  </table>"        + CRLF +;
                        "<br><br>  "        + CRLF +;
                        "Normal Text here"  + CRLF +;
                        "</BODY>"           + CRLF +;
                        "</HTML>"


   DEFINE MAIL oMail;
      SUBJECT  cSubject;
      TEXT     cMessage

   oMail:aRecipients := aRecip
   oMail:aFiles      := aAttach

   ACTIVATE MAIL oMail

   oMail:End()


But it may be the recipient doesn't see the mail as html-formatted.
This depends on the settings of his email reader.

I hope this helps, otherwise ask me again.

Regards,
Detlef
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
TMail with html body and attachment
Posted: Fri Jul 06, 2007 08:04 PM

Hi Detlef,

I will test your example and post results here...

Thanks you for help and attention

Best Regards

Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil

Continue the discussion