Click here to Skip to main content
12,068,967 members (64,952 online)
Click here to Skip to main content
Add your own
alternative version

Stats

233.7K views
3.7K downloads
49 bookmarked
Posted

SMTP Client ActiveX component

, 24 Sep 2002
Rate this:
Please Sign up or sign in to vote.
An SMTP Client ActiveX component, that can be used in ASP, VC, VB, Excel etc.

Introduction

Smtp.Server is an ActiveX component that you may use to send emails. It may be used in Excel, ASP, VB, Visual C++ and other ActiveX container applications. (Please read the write up below for details on how to use Smtp.Server).

I made this component just for the fun of it. It is absolutely free, and like all free software, it has no guarantee and/or liability. Although I have tested it, I do not make any guarantees and accept liabilities (just saving my neck Smile | :) ).

Please read the complete document (given below), before reporting any bug(s) or giving your feedback.

Installation Instructions

Step (1):

Download source and EXE.

Step (2):

Once downloaded, double click SMTPServ.EXE. It is a self-extracting WinZip file. Unzip this file to the directory of your liking. Double click the newly unzipped file (SMTP.EXE). You should see a dialog box similar to the one given below:

Sample Image - smtp.gif

This indicates SMTP.Server has been successfully registered in the system Registry.

If you do not see this dialog box, please report the bug. (Remember that the application has not been tested on Win95/NT.)

Step (3):

Now, you are all set to use it in your Visual C++ applications (as CreateDispatch(“SMTP.Server”)), ASP/Excel/VB applications (as Server.CreateObject(“SMTP.Server”)).

Please go through the example code, and the methods/properties supported by SMTP.Server.

SMTP.Server Properties

SMTP.Server Methods

SMTP.Server Properties

  • LoginName

    Type: String.

    Default Value: “guest”.

    Description: Although the SMTP.Server does not require any user authentication, this parameter is given just for the heck of it! It's up to the user how he/she uses it. The only time when SMTP.Server uses this parameter is when it makes log entries. The LoginName will be written in the log entries so that you may identify the user whose mail was sent through the SMTP.Server. This may be a good tool for billing purposes. In a perfect world, the LoginName may be derived from MailFrom parameter. (normally MailFrom = LoginName@some.server.com, but there may be aliases and other mumbo jumbo that renders this technique, of determining the user, useless.)

    Back to top

  • Password

    Type: String

    Default Value: “guest”

    Description: SMTP.Server does not use this entry at all. This entry has been put there for saving the password. It's up to you to decide how you use it. Unlike LoginName, the Password is not entered in the log file. Why I put the password at all, is a mystery even to me. It's just that login name and password are like twins, so when I put the login name there (and for good reasons too, see the LoginName description), I automatically made an entry for Password.

    Back to top

  • MailTo

    Type: String

    Default Value: null

    Description: This property holds the destination email address. Only one destination address should be given here. If you want the email to be sent to multiple destinations, then use the CcTo property to specify other email addresses. You must set this property to a valid address before calling SendMail( ) method.

    Back to top

  • MailFrom

    Type: String

    Default Value: null

    Description: This property should be set with the sender’s address. If the sender’s address is not given, SMTP.Server checks the ReplyTo property. If ReplyTo property contains an email address, it will be used as the sender address. In case neither MailFrom nor ReplyTo is set, the system returns with an error “Invalid Sender address”.

    Back to top

  • SenderIP

    Type: String

    Default Value: “kashif.SMTP.Server”

    Description: This property should be set to the IP address of the machine that runs SMTP.Server component. If you do not set this property, it defaults to “Kashif.SMTP.Server”.

    Back to top

  • PortNumber

    Type: integer

    Default Value: 25

    Description: The default SMTP listening port is 25. You should not change this unless you have good reasons to do so.

    Back to top

  • ServerVersion

    Type: integer

    Default Value: 1

    Description: This is a read-only property. You cannot set its value. You can only retrieve its value.

    Back to top

  • SMTPServer

    Type: String

    Default Value: “mail.nexlinx.net.pk”

    Description: SMTP.Server does not deliver the email directly to the destination address specified in MailTo and CcTo properties. It passes on the email message to another server which in turn will send the message to the destination(s) on SMTP.Server’s behalf. It is similar to how other email clients (like Eudora, Exchange etc.) handle email delivery. You should specify the mail server’s IP address through the SMTPServer property. The server address could either be descriptive like “mail.nexlinx.net.pk” (my ISP’s mail server address) or an actual IP address like “202.59.64.7”. If you do not set this property, it defaults to “mail.nexlinx.net.pk”. I strongly recommend that you set this property to your own ISP/company’s mail server, since “mail.nexlinx.net.pk” probably has a policy to reject requests originating from domains other than “*.nexlinx.net.pk”.

    Back to top

  • EnableLog

    Type: boolean

    Default Value: 0 (FALSE) I.e., logs will not be maintained.

    Description: This property indicates to the SMTP.Server whether it should keep a log of all the Send Mail requests or not. If this parameter is set then the server will log complete communication to and from the destination SMTPServer (as mentioned in the parameter SMTPServer). You may use the log for billing purposes, to stop hacking, to debug the program etc. How you use it and why you need it, is completely up to you.

    See Also: LogFile

    Back to top

  • Property: LogFile

    Type: String

    Default Value: “C:\SMTPLog.txt

    Description: When you set the EnableLog parameter to true, SMTP.Server attempts to open the file as determined by the “LogFile” parameter. In case the file already exists, the server will start appending the log entries to it. If the file does not exist, the server will create a new file.

    Remember that the server only creates new file and not the directories. So, if you have set LogFile to “C:\logs\Smtp.txt” then make sure that the directory “c:\logs\” exists. If it does not exist then the server will discard the entry and will start appending in the default “C:\SMTPLog.txt” file. In case the file name is invalid, or the server could not create a file, it will start making log entries to the default file “C:\SMTPLog.txt”.

    You may enable logging and have a look at the generated log file, to see the syntax, and the level of information that the file maintains. You may use customized parsing scripts/programs that would parse the log file and implement your billing system, or to prevent spam, malicious emails etc. However, to make this meaningful, you should first set the LoginName parameter before calling the SendMail() method. See Example.asp for details:

    An excerpt from the log file is given below:

    BEGIN <Kashif> 
    Message intended for 4 addresses 
    HIM: 220 mail.nexlinx.net.pk ESMTP Nexlinx 
         Sendmail 8.9.3/8.9.3; Thu, 31 May 2001 14:09:01 +0500 
    ME: HELO kashif.SMTP.Server 
    HIM:250 mail.nexlinx.net.pk Hello [202.59.64.117], pleased to meet you 
    ME: MAIL FROM: <kashifmanzoor@giki.edu.pk> 
    HIM:250 <kashifmanzoor@giki.edu.pk>... Sender ok 
    ME: RCPT TO: <kashifmanzoor@hotmail.com> 
    HIM:250 <kashifmanzoor@hotmail.com>... Recipient ok 
    ME: RCPT TO: <kashifmanzoor@yahoo.com> 
    HIM:250 <kashifmanzoor@yahoo.com>... Recipient ok 
    ME: RCPT TO: <00030022@lums.edu.pk> 
    HIM:250 <00030022@lums.edu.pk>... Recipient ok 
    ME: RCPT TO: <naveedarshad@yahoo.com> 
    HIM:250 <naveedarshad@yahoo.com>... Recipient ok 
    ME: DATA 
    HIM:354 Enter mail, end with "." on a line by itself 
    ME: 
      Subject: This email comes to your courtesy of SMTP.Server 
      Reply-To: kashifmanzoor@giki.edu.pk 
      <55 bytes of message sent to the server> 
      . 
    HIM:250 OAA04529 Message accepted for delivery 
    Message Successfully delivered 
    ======== END ========

    There you have it! Use this log file as you please. The messages sent by SMTP.Server start with the ME tag, and the messages that are received by SMTP.Server start with the HIM tag. Every new log entry starts with a BEGIN tag and ends with END tag; however, if an error occurs while sending the mail, the END tag will not be present. So a missing END tag should indicate an error. To get the details of the error, simply see the corresponding HIM: line

    Back to top

  • Property: ReplyTo

    Type: String

    Default Value: null

    Description: This property should be set with the address at which you want the receiver to reply. If ReplyTo is not set, SMTP.Server automatically treats the address in MailFrom property as ReplyTo. This property is useful when the MailFrom address is different than ReplyTo; in case they are both the same, you may safely ignore ReplyTo.

    Back to top

  • Property: TimeOut

    Type: integer

    Default Value: 180 seconds (3 minutes)

    Description: This value specifies (in seconds) how long should the SMTP.Server take for a single email message. The timer starts when you call SendMail() method. If the SendMail() method does not return (with or without an error) within TimeOut seconds, SMTP.Server will forcibly abort the mail message. This safeguards your container applications from blocking after a call to SendMail().

    Back to top

  • Subject

    Type: String

    Default Value: “(no subject)”

    Description: This property holds the message subject. You can either set the mail subject through this property, or during the call to SendMail() as an input parameter. (See SendMail() method description.)

    Back to top

  • Message

    Type: String

    Default Value: null

    Description: This property holds the actual message. You can either set the message through this property or during the call to SendMail() as an input parameter. (See SendMail() method description.)

    Back to top

  • CcTo

    Type: String

    Default Value: null

    Description: In case your email is destined to multiple addresses, you can specify them through this property. To enter multiple addresses, separate them with a “,” (comma). E.g.: “abcd@efg.com, hij@klm.com, mno@pqr.com”. Note that every address except the last ends with a comma. SMTP.Server ignores any invalid addresses, and does not indicate any error. An invalid address could either be an address without an “@” in it, or an address list not separated by “,”. SMTP.Server, however, does remove any leading/trailing spaces from the addresses.

    Back to top

  • WMLOutput

    Type: boolean

    Default Value: 0 (FALSE) (i.e., output from SendMail() will not be compatible with the WML)

    Description: When you call SendMail() method, it returns a string that indicates the success or failure of the operation. This string may be used verbatim by your program to report the outcome of send mail process. However, if you are embedding SMTP.Server for sending email through a WAP (Wireless Application Protocol) device (e.g., your mobile phones, Handheld PCs etc.) then you must set this parameter to “1”. The reason is that the return message may contain illegal characters like angled brackets “<” or “>”. Although an HTML page may overlook these, a WML browser gets confused and tries to interpret it as a start/end of a WML tag, hence generating a serious “page cannot be displayed” error.

    Setting this property to “1” will ensure that the return message from SendMail() method is compatible with WML code (i.e., all the ambiguities are removed from the return string), and you may output the SendMail() return string directly to a WAP device. See Example WML Code.

    Back to top

  • SendMail (strCc, strSubject, strMessage, strAttachFile)

    SMTP.Server supports only one method (life doesn’t get any easier than this!). The parameters are pretty self explanatory.

    The method takes in the following parameters:

    • strCc: A string that holds the comma separated destination email addresses (see CcTo property).

    • strSubject: A string that holds the subject of the email message (see Subject property).

    • strMessage: A string that holds the actual message to be sent through email (see Message property).

    • strAttachFile: At the moment, SMTP.Server does not allow attachments to your messages. In the future versions, I will implement this feature, at which time this parameter will take in the attached file name. As of now, you may set it to an empty string or to any other value for that matter – SMTP.Server simply ignores it.

    You can either pass on the Cc/Subject/Message information directly through the SendMail() method call, or you can set these individually by accessing the properties directly. If you set these properties individually then make sure you call SendMail() method with empty strings as parameters. This is because the Subject/Cc/Message values passed directly as parameter to SendMail() call take precedence over any previously set values of Subject, CcTo, Message properties. (See Example ASP Code.) SendMail() method was slightly updated on Feb 15, 2002 in accordance to the feedback of Brian D Pearson.

    Return Value:

    The function returns a string that explains the outcome of the SendMail(). If the message is delivered successfully, the return string will contain “Message Successfully delivered”; else it will contain a description of any error that might have occurred.

    Back to top

Example Usage

Send bugs/feedback/criticism to: kashifmanzoor@hotmail.com.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Kashif Manzoor
Web Developer
United Kingdom United Kingdom
I have 8 years of industry experience and am currently pursuing my graduate studies at University of Illinois at Urbana Champaign.

You may also be interested in...

Comments and Discussions

 
GeneralUninstaller for this COM component Pin
daluu1-Nov-08 20:33
memberdaluu1-Nov-08 20:33 
GeneralActiveX/COM send mail without specifying SMTP server Pin
daluu1-Nov-08 20:27
memberdaluu1-Nov-08 20:27 
QuestionHow Can i use SMTP Client ActiveX Component ? Pin
khan78620-Aug-07 1:27
memberkhan78620-Aug-07 1:27 
AnswerRe: How Can i use SMTP Client ActiveX Component ? Pin
daluu1-Nov-08 20:28
memberdaluu1-Nov-08 20:28 
GeneralJavascript Pin
MaTrIX2k227-May-06 17:00
memberMaTrIX2k227-May-06 17:00 
GeneralRe: Javascript Pin
daluu1-Nov-08 20:31
memberdaluu1-Nov-08 20:31 
GeneralUsing ActiveX Componets in VBS Pin
eduardo silva31-May-04 6:16
membereduardo silva31-May-04 6:16 
GeneralRe: Using ActiveX Componets in VBS Pin
daluu1-Nov-08 20:30
memberdaluu1-Nov-08 20:30 
GeneralEmpty &quot;From&quot; box Pin
Nea Gicu23-Oct-03 17:12
memberNea Gicu23-Oct-03 17:12 
GeneralRe: Empty &quot;From&quot; box Pin
Kashif Manzoor10-Dec-03 1:00
memberKashif Manzoor10-Dec-03 1:00 
GeneralRe: Empty "From" box Pin
Eric Sontag3-May-10 7:19
memberEric Sontag3-May-10 7:19 
QuestionWHere's the Object for C++? Pin
alan9310-Jun-03 8:57
memberalan9310-Jun-03 8:57 
AnswerRe: WHere's the Object for C++? Pin
Kashif Manzoor10-Dec-03 1:07
memberKashif Manzoor10-Dec-03 1:07 
Generalmicrosoft exchange server 2000 plugin Pin
sheshtawy31-May-03 23:00
susssheshtawy31-May-03 23:00 
GeneralEdu Pin
eduardo silva6-Dec-02 10:26
membereduardo silva6-Dec-02 10:26 
GeneralRe: Edu Pin
Kashif Manzoor9-Dec-02 21:08
memberKashif Manzoor9-Dec-02 21:08 
GeneralRe: Edu Pin
eduardo silva10-Dec-02 3:44
membereduardo silva10-Dec-02 3:44 
GeneralNo Support For SMTP Auth Standard Pin
Fred26-Sep-02 6:08
memberFred26-Sep-02 6:08 
GeneralRe: No Support For SMTP Auth Standard Pin
Kashif Manzoor26-Sep-02 21:58
memberKashif Manzoor26-Sep-02 21:58 
GeneralRe: No Support For SMTP Auth Standard Pin
MrGoodly24-Nov-06 9:23
memberMrGoodly24-Nov-06 9:23 
GeneralCcTo and Message do not work Pin
Thomas Wohlgemuth13-Sep-02 5:29
sussThomas Wohlgemuth13-Sep-02 5:29 
GeneralRe: CcTo and Message do not work Pin
Kashif Manzoor24-Sep-02 22:21
memberKashif Manzoor24-Sep-02 22:21 
GeneralSmtp server like hotmail blocks me. Pin
Ofer12345-Aug-02 0:15
sussOfer12345-Aug-02 0:15 
GeneralRe: Smtp server like hotmail blocks me. Pin
PunkVal22-Nov-05 9:19
memberPunkVal22-Nov-05 9:19 
QuestionHow to add attachment files? Pin
john wann23-Jul-02 20:20
memberjohn wann23-Jul-02 20:20 
AnswerRe: How to add attachment files? Pin
Kashif Manzoor24-Jul-02 0:35
memberKashif Manzoor24-Jul-02 0:35 
GeneralRe: How to add attachment files? Pin
john wann24-Jul-02 1:49
memberjohn wann24-Jul-02 1:49 
QuestionRe: How to add attachment files? Pin
andrewtruckle28-Sep-06 5:35
memberandrewtruckle28-Sep-06 5:35 
QuestionSMTP,poxy -Hiding Original IP address-anybody have any idea? Pin
Hirosh Joseph26-Feb-02 16:34
memberHirosh Joseph26-Feb-02 16:34 
AnswerRe: SMTP,poxy -Hiding Original IP address-anybody have any idea? Pin
Kashif Manzoor26-Feb-02 22:05
memberKashif Manzoor26-Feb-02 22:05 
GeneralRe: SMTP,poxy -Hiding Original IP address-anybody have any idea? Pin
Hirosh Joseph27-Feb-02 0:43
memberHirosh Joseph27-Feb-02 0:43 
Generalthat will not work Pin
Hirosh Joseph27-Feb-02 1:08
memberHirosh Joseph27-Feb-02 1:08 
GeneralRe: that will not work Pin
Kashif Manzoor27-Feb-02 3:01
memberKashif Manzoor27-Feb-02 3:01 
GeneralRe: that will not work Pin
Hirosh Joseph27-Feb-02 6:06
memberHirosh Joseph27-Feb-02 6:06 
Generalwindows 2000 Pin
Anonymous26-Feb-02 7:05
memberAnonymous26-Feb-02 7:05 
GeneralRe: windows 2000 Pin
Kashif Manzoor26-Feb-02 22:01
memberKashif Manzoor26-Feb-02 22:01 
GeneralRe: windows 2000 Pin
Rafael Sotomayor29-Sep-02 18:27
sussRafael Sotomayor29-Sep-02 18:27 
GeneralRe: windows 2000 Pin
Jonathan.Oakley6-Apr-05 13:12
memberJonathan.Oakley6-Apr-05 13:12 
QuestionServer? Pin
Matt Newman17-Feb-02 12:34
memberMatt Newman17-Feb-02 12:34 
AnswerRe: Server? Pin
Matt Newman17-Feb-02 12:36
memberMatt Newman17-Feb-02 12:36 
AnswerRe: Server? Pin
Kashif Manzoor17-Feb-02 19:08
memberKashif Manzoor17-Feb-02 19:08 
GeneralCode Project and Source Code Pin
Ray Hayes11-Feb-02 6:53
memberRay Hayes11-Feb-02 6:53 
GeneralRe: Code Project and Source Code Pin
Nish [BusterBoy]11-Feb-02 6:52
memberNish [BusterBoy]11-Feb-02 6:52 
GeneralRe: Code Project and Source Code Pin
Jon Sagara11-Feb-02 10:41
memberJon Sagara11-Feb-02 10:41 
GeneralRe: Code Project and Source Code Pin
Kashif Manzoor11-Feb-02 19:03
memberKashif Manzoor11-Feb-02 19:03 
GeneralRe: Code Project and Source Code Pin
Jon Sagara11-Feb-02 19:18
memberJon Sagara11-Feb-02 19:18 
GeneralRe: Code Project and Source Code Pin
Jon Sagara11-Feb-02 19:22
memberJon Sagara11-Feb-02 19:22 
GeneralRe: Code Project and Source Code Pin
Kashif Manzoor11-Feb-02 19:28
memberKashif Manzoor11-Feb-02 19:28 
GeneralRe: Code Project and Source Code Pin
Jon Sagara11-Feb-02 19:30
memberJon Sagara11-Feb-02 19:30 
GeneralRe: Code Project and Source Code Pin
Kashif Manzoor11-Feb-02 19:36
memberKashif Manzoor11-Feb-02 19:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.160208.1 | Last Updated 25 Sep 2002
Article Copyright 2002 by Kashif Manzoor
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid