TMail with html body and attachment

TMail with html body and attachment

Postby yury » 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:

Code: Select all  Expand view
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... :D

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...
:(

Code: Select all  Expand view
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 :wink:
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Postby yury » Fri Jul 06, 2007 1:48 pm

nothing ????
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Postby Detlef Hoefner » Fri Jul 06, 2007 2: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
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby yury » Fri Jul 06, 2007 5: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
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Postby Detlef Hoefner » Fri Jul 06, 2007 6:59 pm

Hi Yuri,

i don't have Outlook.
But you should use something like the following example:
Code: Select all  Expand view
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
User avatar
Detlef Hoefner
 
Posts: 312
Joined: Sat Oct 08, 2005 9:12 am
Location: Germany

Postby yury » Fri Jul 06, 2007 8: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
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 47 guests