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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send and Recieve Email Add-ons

Status
Not open for further replies.

kstieb

Programmer
Mar 29, 2005
11
CA
I have been working with a couple of very useful and dynamic add-ons over the past while. These dll's function very well in a number of programming environments. Including foxpro.
I am in no way associated with the company, by the way. I feel this is an important contribution to the forum. The costs for these dll's is either free, or very cheap depending on how you plan on using them.

The company is called Ostrosoft. I have utilized their smtp dll in a foxpro program with great success for sending emails. It works and functions great.
In the near future I will be working with the Email receiving dll. I doubt that I will have much for problems as the smtp dll programmed very easily.

The web site of the company is
They have a number of items there worth looking at, that can be utilized in a number of programming languages. While they do not currently have samples available for foxpro, I will be putting something together for them shortly regarding the smtp dll.

If someone wants to see some of the code, I could gladly add it to this thread. I am realistically only using a small part of what the smtp dll can do....and it does a lot. I have also utilzed it in a ms access database and it works flawlessly in that environment as well.

A thought should be given to having a vfp topic forum where posts can be made regarding vfp add-ons and sample program code...it would be a popular area.
 
Examples are good!
Mabee also a discussion of the differences in useing smtp, cdo, and outlook automation would be valuable here
wjwjr
 
1. SMTP (Simple Mail Transfer Protocol), is a common way to send e-mails. Normally you use an SMTP Server (or SMTP service ) to get you mail out of your computer to the client's POP3 account. So it is the "bridge" between your computer to the client's e-mail server.
2. CDO (Colaboration Data Object) is a way of sending an e-mail to an SMTP server. No excactly the same as above. CDO gets the e-mail to the SMTP server.
3. Outlook Automation is another way of creating an e-mail message to be sent.

So in fact the three things above, although related, ar not the same.
P.S. The SMTP dll mentionned above uses winsock the send e-mail to an SMTP server. Outlook uses MAPI and CDO uses Multipurpose Internet Mail Extensions. The serity message that pops up under certain conditions is related to the added security Microsoft added to the MAPI, so in order to avoid it, do not use Outlook for sending e-mail but the in cases above use either CDO or Winsock.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Mike - since you seem to have a good handle on the variety of ways to send email, can you add to how [or if] they can send out FAX's also.

For a while now I have been using VFP7 to automate Outlook (through Redemption) to send out both emails with multiple attachments and FAX's. Our production system typically sends out 150-200 or these email/fax's every morning to clients with the previous day's accumulated data.

To get the FAX's out we are using the Windows Small Business Server (a.k.a. Win 2000 Server) Shared FAX Services. By configuring Outlook to use this as another service, we can send out FAX's via a central (non-workstation specific) service.

I would indeed like to consider eliminating the use of Outlook, but I need to find another means of supporting both the non-workstation specific sending of email and fax's. The new approach does not have to be a single, consolidated method like we are using today, but it does have its convenience.

Any suggestions?

Thanks,
JRB-Bldr
 
Mike,
Exactly what i meant, a better understanding!
A trick I learned just today and cannot take credit for:
Use BCC to carbon yourself, create a rule in outlook to stuff it into the sent box and verify that the mail suceeded
wjwjr
 
For a while I was designing my programs to interface with MS outlook and outlook express. However, I found that to be a problem in a larger environment where people have various versions of things....

This is why I searched for, and found, a simple yet effective solution to the problem. In the programs I have designed I set up a default CC to the sender so they know the email went out okay.

However...I designed another part within the program. The dll (in its events part) allows you to design an area where you can see all the communications with the mail server. I incorporated that into the program, just for fun. I wanted to see if it was something worth having...

Now it has become a part of all the programs I design with email functionality. It aids the user in resolving username password errors, mail errors and a number of other chores most people never see with standard email programs. Some email servers actually do "checks" on email addresses, and if they are wrong (or they think they are wrong) will say so. That is neat.

I will likely post the main part of the code, including the event handling, in the next day or so.

 
Here is the main code I use for the smtp dll. You will get the concept of the events, etc.

* Create object with events based on ossmtp.dll which is located in
* c:\windows\system folder.

oSMTP = NEWOBJECT("OSSMTP.SMTPSession")
oEvents = NEWOBJECT("myClass")
EVENTHANDLER(oSMTP, oEvents)

* Use values from form ossmtp. Server, password, username, authentication
* values are stored in a table. Other values are from text boxes with
* values that can be changed by user.

oSMTP.Server = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtServer.Value)

* Determine if POP3 server, or smtp server requires login auth or plain

DO CASE
CASE (_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtAuthentication.Value = 1)
* POP3 Server
oSMTP.POPServer = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtServer.Value)
oSMTP.Username = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtUsername.Value)
oSMTP.Password = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtPassword.Value)
CASE (_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtAuthentication.Value = 2)
* Login Auth
oSMTP.Username = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtUsername.Value)
oSMTP.Password = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtPassword.Value)
CASE (_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtAuthentication.Value = 3)
* Login Plain
oSMTP.Username = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtUsername.Value)
oSMTP.Password = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtPassword.Value)
ENDCASE

oSMTP.AuthenticationType = INT(_SCREEN.ActiveForm.Pageframe_1.PAGE3.txtAuthentication.Value)
oSMTP.MailFrom = _SCREEN.ActiveForm.Pageframe_1.PAGE1.Text1.Value
oSMTP.SendTo = _SCREEN.ActiveForm.Pageframe_1.PAGE1.Text2.Value
oSMTP.MessageSubject = _SCREEN.ActiveForm.Pageframe_1.PAGE1.Text3.Value
oSMTP.MessageText = _SCREEN.ActiveForm.Pageframe_1.PAGE1.Edit3.Value

* Determine if there are values in the CC field

ccFile = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE1.Edit1.Value)

IF LEN(ccFile) > 0 THEN
oSMTP.CC = ccFile
ENDIF

* Determine if there are values in the BCC field

BccFile = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE1.Edit2.Value)

IF LEN(BccFile) > 0 THEN
oSMTP.BCC = BccFile
ENDIF

* Determine if there is a value in Edit4 that references a file to be
* attached to the email. If there is, attach it to the email using
* the attachments command.

attFile = TRIM(_SCREEN.ActiveForm.Pageframe_1.PAGE1.Edit4.Value)

IF LEN(attFile) > 0 THEN
oSMTP.Attachments.Add (attFile)
ENDIF

* Send the email

txtStatus = " "
oSMTP.SendEmail()

* Enable events for this dll. Use the defined class listed below
* to give the user a visual confirmation of the email status with the
* smtp server. If there is errors or problems, show them also.
* Other events are included, but not programmed with user code at this
* time.

DOEVENTS

* Display smtp server communication on the form. Or, display any error
* message from the smtp server on the form.

oSMTP = Null
oEvents = Null

* Define events using built in classes of the dll.
* Each event procedure can have custom user code for it.

DEFINE CLASS myClass as Session OLEPUBLIC
IMPLEMENTS __SMTPSession IN "OSSMTP.dll"

PROCEDURE __SMTPSession_StatusChanged(Status as String) as VOID
* Display smtp server communication on the form.
txtStatus = txtStatus + oSMTP.Status + CHR(13)
_SCREEN.ActiveForm.Pageframe_1.PAGE3.Edit1.Value = txtStatus
ENDPROC

PROCEDURE __SMTPSession_CloseSMTP() as VOID
* Connection closed
txtStatus = txtStatus + "*----* Disconnected From " + _SCREEN.ActiveForm.Pageframe_1.PAGE3.txtServer.Value + CHR(13)
_SCREEN.ActiveForm.Pageframe_1.PAGE3.Edit1.Value = txtStatus
_SCREEN.oapp.omessage.displaymessage("SMTP Disconnected")
ENDPROC

PROCEDURE __SMTPSession_ConnectSMTP() as VOID
* Connected to Server and authenticated
txtStatus = txtStatus + "*----* Login OK with " + _SCREEN.ActiveForm.Pageframe_1.PAGE3.txtServer.Value + CHR(13)
_SCREEN.ActiveForm.Pageframe_1.PAGE3.Edit1.Value = txtStatus
_SCREEN.oapp.omessage.displaymessage("SMTP Connected")
ENDPROC

PROCEDURE __SMTPSession_SendSMTP() as VOID
* Message successfully sent
txtStatus = txtStatus + "*----* Email sent successfully via " + _SCREEN.ActiveForm.Pageframe_1.PAGE3.txtServer.Value + CHR(13)
_SCREEN.ActiveForm.Pageframe_1.PAGE3.Edit1.Value = txtStatus
ENDPROC

PROCEDURE __SMTPSession_MessageSaved() as VOID
* Message successfull
ENDPROC

PROCEDURE __SMTPSession_ErrorSMTP(Num as Integer, Description as String) as VOID
* Error Occured so display on form for user
txtStatus = txtStatus + "Error " + Num + ": " + Description + CHR(13)
_SCREEN.ActiveForm.Pageframe_1.PAGE3.Edit1.Value = txtStatus
_SCREEN.oapp.omessage.displaymessage("SMTP Error")
ENDPROC

ENDDEFINE
 
white605.
White605 said:
A trick I learned just today and cannot take credit for:
Use BCC to carbon yourself, create a rule in outlook to stuff it into the sent box and verify that the mail suceeded

It depends, if you are using CDO, a BCC is a trick that means "The BCC was successful", which means the BCC address was OK and got through, but that still does not mean the intended recipient got his. If it is CDO that a look at the DSN (Delivery Status Notification) property, if you ste it to 14 it will return a message to the sender if it fails, or was delayed, or succeeded.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
JRB

JRB said:
I would indeed like to consider eliminating the use of Outlook, but I need to find another means of supporting both the non-workstation specific sending of email and fax's.

Considering eliminating Outlook to fax, means your next slight step is Microsoft Fax Server, easy to configure, and you can automate also quite easily. There are few few step required to achieve this (not of the fax server side, but rather on the VFP side, you need to use the Report Listener from VFP9 to produce a CCITT Group 4 Fax type fax). But is that is the way you want to go, let me know, I have written an article on the subject (In french) I can point you to.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top