Sending HTML using MAIL

Sending HTML using MAIL

Postby TimStone » Tue Apr 04, 2023 11:33 pm

The following code works fine with MAPI

Code: Select all  Expand view

      DEFINE MAIL oMail ;
         SUBJECT cSubj ;
         TEXT cText ;
         FILES cSndFile, cSndFile ;
         FROM USER ;
         TO MailTo
      ACTIVATE MAIL oMail
 


However, I want to start the email ( in Outlook via MAPI ) as HTML.

I added the following:

LOCAL cType := 'txt/html'

Then I added the following to the call above:
TYPE cType

In the documentation, TYPE is a valid addition. However, when I add this in, then I get the message "The object cannot be found".

I have a ( nagging ) client who wants to add a signature and graphic to his outgoing emails, and that requires HTML.

Any thoughts on this ?
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Sending HTML using MAIL

Postby karinha » Wed Apr 05, 2023 10:39 am

Use the google translator. Example:

https://www.tecmundo.com.br/internet/125736-crie-assinatura-html-padronizada-contas-mail.htm

HTML signature template. Use your editor and modify for your data.

Code: Select all  Expand view

<hr size="1" />
<table>
  <tr>
    <td style="font-family:tahoma,arial,verdana; font-size:11px; text-align:center" valign="top">
      <a href="https://www.SEUSITE.com.br" target="_blank"><img src="https://goo.gl/Y7AqYY" border="0" /></a>
    </td>
    <td style="font-family:tahoma,arial,verdana; font-size:12px; padding-left:10px">
      <strong>YOUR NAME/NOME</strong>
      <br />
      <strong>Phone/Fone:</strong> (XX) xxxx xxxx (XX) xxxx xxxx
      <br />
      <strong>Site:</strong> <a href="https://www.tecmundo.com.br/" target="_blank">https://www.tecmundo.com.br/</a>
      <br />
      <strong>Twitter:</strong>@Tec_Mundo
      <br /></td> </tr></table>
 


see signature edit:

https://jsfiddle.net/am70dce3/3/

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7794
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Sending HTML using MAIL

Postby karinha » Wed Apr 05, 2023 10:52 am

More example:

https://www.oficinadanet.com.br/post/14907-como-criar-uma-assinatura-em-html-para-email

Signatur.htm

Code: Select all  Expand view

<hr />
<table>
    <tr>
        <td style="font-family:arial; font-size:11px; text-align:center" valign="top">
            <a href="LINKAQUI" target="_blank">
                <img src="PHOTO.JPG" border="0" />
            </a>
        </td>
        <td style="font-family:arial; font-size:12px; padding-left:10px">
            <strong>João Santos</strong><br />
            <strong>Fone:</strong> +55(11)95150-7341<br />
            <strong>Site:</strong> <a href="www.fivewin.com.br" target="_blank">www.fivewin.com.br</a><br />
            <strong>Twitter/Instagram:</strong>www.facebook.com/kapiaba<br />
            <strong>SKYPE:</strong> joao@pleno.com.br
        </td>
    </tr>
</table>
<hr />
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7794
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Sending HTML using MAIL

Postby TimStone » Wed Apr 05, 2023 5:53 pm

Thank you ....but I don't think that addresses the issue.

Using the tMail class, I am sending the address, subject, and text to a MAPI client ( ie. Outlook ). That client has the signature built in. When using MAPI, the client displays the the email form, but it is in standard text, not HTML, format. To use a signature it must be in HTML.

I believe TYPE in the tMail class is to tell the client to set it to HTML. However, I need the correct command content and IT IS NOT DOCUMENTED.

I will save your info incase I move to HTML generated emails in my application, and appreciate it, but for now the customer is demanding I make his email client default to use his signature stored within it. Of course, that shouldn't be my problem, but he LOVES to COMPLAIN about anything.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Sending HTML using MAIL

Postby Antonio Linares » Wed Apr 05, 2023 6:57 pm

Dear Tim,

Microsoft docs about lpszMessageType is not very clear:
https://learn.microsoft.com/en-us/windows/win32/api/mapi/nc-mapi-mapisendmailw
Used by applications that do not handle interpersonal messages. If your application handles interpersonal messages, set the lpszMessageType member to NULL or set it to point to an empty string.


I have asked to chatGPT and got this:
lpszMessageType is a string parameter that specifies the message type of the email being sent. In the context of MAPISendMail function, the message type is usually specified using one of the predefined message classes that are defined in the Messaging Application Programming Interface (MAPI) specification.

Here are some of the common values for lpszMessageType parameter:

"IPM.Note" - a regular email message
"IPM.Appointment" - an appointment or meeting request
"IPM.Contact" - a contact or address book entry
"IPM.Task" - a task or to-do item
"IPM.StickyNote" - a sticky note or memo
There are many other message classes defined in the MAPI specification, and custom message classes can also be defined by developers. When creating custom message classes, the class name should follow the format "IPM.<custom name>".


Then I kept asking it for an example and got this:
To send HTML content in an email, you can use the "IPM.Note" message class with the message format set to MAPI's rich-text format.

To do this, you can set the ulReserved field of the MapiMessage structure to 0, and set the flFlags field to MAPI_HTML


which has no sense for me. It may be wrong
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sending HTML using MAIL

Postby Antonio Linares » Wed Apr 05, 2023 6:59 pm

regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sending HTML using MAIL

Postby TimStone » Wed Apr 05, 2023 7:12 pm

Antonio,

Unfortunately that is for Outlook 2007. Microsoft has made major changes to Outlook and ( reportedly ) is trying to remove it from handling MAPI services. They want to take it all online.

Another post on this forum suggested TYPE 'txt/html' but that returns the message the object can't be found. I assume that means Outlook could not create the object ( email form ) to display because of the TYPE designator.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Sending HTML using MAIL

Postby Antonio Linares » Thu Apr 06, 2023 6:54 am

Dear Tim,

We are going to create an example here to test it to see what we find

many thanks for your great feedback
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sending HTML using MAIL

Postby Antonio Linares » Thu Apr 06, 2023 7:14 am

Dear Tim,

Without specifying a TYPE value, please send this text:
Code: Select all  Expand view
  DEFINE MAIL oMail ;
      SUBJECT "Testing..." ;
      TEXT "<html><head></head><body>This is real xBase power at your fingertips!</body></html>" ;
      FROM USER ;
      RECEIPT

if you don't get any HTML, then please add your TYPE clause
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Sending HTML using MAIL

Postby TimStone » Fri Apr 07, 2023 11:59 pm

I tried it. All I got was the html code in the message.

Others suggested: TYPE 'n' ;
That just gives me an object not found response. In other words, it could not create the email object using a TYPE variable
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2943
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Sending HTML using MAIL

Postby Antonio Linares » Sat Apr 08, 2023 6:04 am

Dear Tim,

I have modified FWH\samples\testmail.prg but when I try to connect to MAPI I get:

there is no email associated to perform the requested action. Please install an email program or, if one is already installed, create an association in the Default Programs control panel


I have no idea how to solve this on Windows 11. I have been reviewing videos and google for it, but no solution found yet
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 59 guests