Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SMTP with HTML text

Status
Not open for further replies.

RoadRunnerOz

Programmer
Aug 22, 2000
128
AU
Anyone know about a program that allows a user to type in HTML format (Something like the rtf control ) then allow SMTP emailing? I know this may be two seperate programs/problems but I'm stuck right now.

West Wind Technologies allows sending HTML as an attachment only so they're out.
I tried the rtf ocx but the message sent always ends up with all the formatting junk in it.

I need to be able to email from noexistant mailboxes, and yes this is a legit operation, its done all the time.

The users have to respond to tech questions in the body of the message.

The top must have some url's, a picture, some formatted text

The footer must also contain the same as the top/header.

Thanks for any help yo'all got.

The YankDownUnder
- Mike


[sig]<p>Michael Ouellette<br><a href=mailto:mouellette@globalfreeway.com.au>mouellette@globalfreeway.com.au</a><br>[/sig]
 
Maybe I dont understand what you're doing but whats wrong with Outlook Express or other email application or don't even web based free email like Yahoo and others allow HTML formatting in a message? [sig]<p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>MCP Visual FoxPro<br>
<br>
ICQ #9466492<br>
ICQ VFP ActiveList #73897253[/sig]
 
None of the users have email/web access on their PC's( as a security issue) Management decision not to let them have it. AND
more importantly you cannot email anyone from a nonexistant address in Outlook, Express etc.

Mike

[sig]<p>Michael Ouellette<br><a href=mailto:mouellette@globalfreeway.com.au>mouellette@globalfreeway.com.au</a><br>[/sig]
 
I still don't understand why West-Wind SMTP object does not works with HTML content. AFAIK, their object have Content Type property. Who knows, is it used?
Finally, when you can send EMail via SMTP, you can ALWAYS configure Outlook to send EMail through HTTP too. So you will use Outlook just instead of West-Wind SMTP object. [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
html is sent as an attachment in west wind... I've already exhausted their program. Its fine for text only.

Once again the users do NOT have Outlook. My company is not going to give operators access to the WEB nor purchase 35 additional licenses. I have to find another way...

Cheerio [sig]<p>Michael Ouellette<br><a href=mailto:mouellette@globalfreeway.com.au>mouellette@globalfreeway.com.au</a><br>[/sig]
 
Michael, things are not so bad as you think. You do not need to have Outlook at ALL computers. You nee it just on the server. Do following:
Make server COM object that will receive string (HTML content of mail). It will work on the server and client applications can instantiate it using CreateObjectEx function. A single method call to remote object on the server will solve your problem. This object can use than ANY tools to send EMail just from server. No Outlook at client machines. No security prolems mentioned by you.
Do you like above solution? [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Thanks - Sounds good Vlad... But I have no idea how???
sample code??

Totally new ground for me...





[sig]<p>Michael Ouellette<br><a href=mailto:mouellette@globalfreeway.com.au>mouellette@globalfreeway.com.au</a><br>[/sig]
 
Michael, do you know how to make COM object in VFP? Its class defined as OLEPUBLIC and than compiled into DLL. Than you can call that class by the same way as you call, for example, MS Word OLE object or Outlook OLE object, using CreateObject('MyProject.MyClass') command. The nice thing is that VFP supports DCOM. This means that object can be ran from remote computer. CreateObjectEx function allows you to make this, for example, by following way:
Code:
MyComputer = '\\DataServer'
MyObjectCLSID = {23451-231.....}
CreateObject(MyObjectCLSID, MyComputer)

Example of COM object definition:

DEFINE CLASS MyClass AS Custom OLEPUBLIC

  PROCEDURE SendMail
  lparameters pcTo, pcSubj, pcBody, paATTACHFILES
  local oOutlook, oLogon, OAPPT

* note that this code works on server, so Outlook from server will be used
  oOutlook = CREATEOBJET(&quot;Outlook.Application&quot;) 

* Here we logon. Be sure to configure Outlook on server for automatic logon so COM object will not show logon dialog during this code running.
  oLogon = oOutlook.GETNAMESPACE(&quot;MAPI&quot;) 

  oOutlook.CREATEITEM(1) && this is really needed, otherwise Maill will not be sent immediately after SEND method call
  OAPPT = oOutlook.CREATEITEM(0) && olMailItem
  WITH OAPPT
* populate letter properties
    .SUBJECT = pcSubj
    .BODY = pcBody
    .TO = STRTRAN(allt(pcTo),',',';') && Outlook does not lik comma as separator of EMails
*    .CC = whatever
*    .BCC = whatever
    local lcAttachList
    m.lcAttachList = &quot;&quot;
    IF TYPE(&quot;paATTACHFILES[1]&quot;) = &quot;C&quot; && ARRAY OF ATTACHMENTS IS NOT EMPTY
      local I
      FOR I = 1 TO ALEN(paATTACHFILES)
        IF VARTYPE(paATTACHFILES[I]) = &quot;C&quot; AND FILE(paATTACHFILES[I]) &&add attachment file if it exists
          .Attachments.Add(paATTACHFILES[I]) 
        ENDIF	
      ENDFOR	
    ENDIF
    .SEND
  ENDWITH

  rele oLogon
  rele oOutlook
  
  ENDPROC

ENDDEFINE

Compile project that contains above class into DLL and install on your server by registering it using RegSVR32.exe - Windows standard tool. Note CLSID (Class unique ID), you can retrieve it from files generated together with DLL or from project AFTER compiling. Note that recompiling of DLL may change Class ID in some cases, so better be accurate here.

On the client application just put code:

oMyMailSender = CreateObjectEx('{12321-...}', '\\MyDataServer')
oMyMailSender.SendMail(...)
rele oMyMailSender

Because object initialization is somewhat slower through network, you may try to initialize it at application start and free after application shutdown, but this is not recommended unless you going to use MTS at the server side.
You may also call object by 'MyProject.MyClass', but you will need to make some installation at the client computers for DCOM (MTS allows to simplify this). I guess CLSID way is better because you do not need to install something additional at each client computer.
Hope this helps. [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
There has been a series on automating Outlook in FoxPro Advisorif that's any help. [sig]<p>John Durbin<br><a href=mailto: john@johndurbin.com> john@johndurbin.com</a><br><a href= </a><br>MCP Visual FoxPro<br>
ICQ VFP ActiveList #73897253[/sig]
 
Vlad:

You're great! Thanks I'll try this over the next couple of days after we go live with the text-only app. But I believe this solves half the problem. The other half is to compose in html or convert their screen response to html. I'll also have to check if this allows the sender address to be invalid in any address book.( cause the addresses do not exist at our site)
- Thanks heaps mate, you got me heading in the right direction.


John Durbin: I have used Outlook many times in the past but not without outlook directly available to the user.
-Thanks
[sig]<p>Michael Ouellette<br><a href=mailto:mouellette@globalfreeway.com.au>mouellette@globalfreeway.com.au</a><br>[/sig]
 
Michael, You may try third-party ActiveX components for HTML. I beleive there are some components like RTF control that allow you to make HTML text. Finally, MS Word can be used to compose HTML documents too. [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
I finally worked out your code Vlad. No problem. You did have some typos and left out some code but I worked it out.
Took me forever to figure out clsid! Its a 30 character string! Thanks heaps for the kick in the right direction.

Can multiple users access this com object at the same time?
(I workin' from home over the holidays so I can't test in the live environment. )
Since I need to compose in html WITH formatting I have to make outlook visible ( OAPPT.display ) Is there a way to turn off the main menu? and/or selected options so nothing can be changed by these users?

Thanks

Michael Ouellette
mouellette@globalfreeway.com.au
 
Yes, multiple users can access remote COM object. However, each user will have its own instance of COM object. You can register COM object under MTS on the serever machine. This will allow multiple users to connect to the same object. Say, 100 users work with 10 objects. However, COM object in such case should be made stateless, that means - nothing stored in object except common cashe. This because MTS handles all calls and you cannot predict exact order of all calls rocessing. This means - you cannot use code like following:

oMyRemoteObject.StartProcessing(SomeParameter)
oMyRemoteObject.GetResultOfProcessing()

All actions should be made in a single call, like following:

oMyRemoteObject.GetResultsOfProcessing(SomeParameter)

and call of StartProcessing method should be already inside of COM object.

There are many articles in MSDN related to MTS and COM objects.



Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
>>There are many articles in MSDN related to MTS and COM objects. << I'll check it out Thanks


Michael Ouellette
mouellette@globalfreeway.com.au
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top