SMTP Client ActiveX component
来源:互联网 发布:无线鼠标接收器的端口 编辑:程序博客网 时间:2024/06/06 00:26
SMTP Client ActiveX component
By Kashif Manzoor- Download source code - 18.7 Kb
- Download EXE - 176 Kb
Introduction
Smtp.Server
is an ActiveX component that you may use tosend emails. It may be used in Excel, ASP, VB, Visual C++ and otherActiveX container applications. (Please read the write up below fordetails 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 acceptliabilities (just saving my neck :-)).
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:
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
- LoginName
- Password
- MailTo
- MailFrom
- CcTo
- Subject
- Message
- ReplyTo
- SMTPServer
- SenderIP
- PortNumber
- ServerVersion
- EnableLog
- LogFile
- TimeOut
- WMLOutput
SMTP.Server Methods
- SendMail()
SMTP.Server Properties
LoginName
Type: String.
Default Value: “guest”.
Description: Although the
SMTP.Server
does notrequire any user authentication, this parameter is given just for theheck of it! It's up to the user how he/she uses it. The only time whenSMTP.Server
uses this parameter is when it makes log entries. TheLoginName
will be written in the log entries so that you may identify the user whose mail was sent through theSMTP.Server
. This may be a good tool for billing purposes. In a perfect world, theLoginName
may be derived fromMailFrom
parameter. (normallyMailFrom
=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 entryat all. This entry has been put there for saving the password. It's upto you to decide how you use it. UnlikeLoginName
, thePassword
is not entered in the log file. Why I put the password at all, is amystery even to me. It's just that login name and password are liketwins, 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 emailaddress. Only one destination address should be given here. If you wantthe 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 callingSendMail( )
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 theReplyTo
property. IfReplyTo
property contains an email address, it will be used as the sender address. In case neitherMailFrom
norReplyTo
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 inMailTo
andCcTo
properties. It passes on the email message to another server which in turn will send the message to the destination(s) onSMTP.Server
’sbehalf. It is similar to how other email clients (like Eudora, Exchangeetc.) handle email delivery. You should specify the mail server’s IPaddress through theSMTPServer
property. The serveraddress could either be descriptive like “mail.nexlinx.net.pk” (myISP’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 ownISP/company’s mail server, since “mail.nexlinx.net.pk” probably has apolicy 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. Ifthis parameter is set then the server will log complete communicationto and from the destinationSMTPServer
(as mentioned in the parameterSMTPServer
).You may use the log for billing purposes, to stop hacking, to debug theprogram etc. How you use it and why you need it, is completely up toyou.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 startappending the log entries to it. If the file does not exist, the serverwill 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 andwill start appending in the default “C:/SMTPLog.txt” file. In case thefile name is invalid, or the server could not create a file, it willstart making log entries to the default file “C:/SMTPLog.txt”.You may enable logging and have a look at the generated log file, tosee the syntax, and the level of information that the file maintains.You may use customized parsing scripts/programs that would parse thelog file and implement your billing system, or to prevent spam,malicious emails etc. However, to make this meaningful, you shouldfirst set the
LoginName
parameter before calling theSendMail()
method. See Example.asp for details:An excerpt from the log file is given below:
CollapseBEGIN <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 theME
tag, and the messages that are received bySMTP.Server
start with theHIM
tag. Every new log entry starts with aBEGIN
tag and ends withEND
tag; however, if an error occurs while sending the mail, theEND
tag will not be present. So a missingEND
tag should indicate an error. To get the details of the error, simply see the correspondingHIM:
lineBack 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 inMailFrom
property asReplyTo
. This property is useful when theMailFrom
address is different thanReplyTo
; in case they are both the same, you may safely ignoreReplyTo
.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 theSendMail()
method does not return (with or without an error) withinTimeOut
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 multipleaddresses, you can specify them through this property. To entermultiple addresses, separate them with a “,” (comma). E.g.:“abcd@efg.com, hij@klm.com, mno@pqr.com”. Note that every addressexcept the last ends with a comma.
SMTP.Server
ignoresany invalid addresses, and does not indicate any error. An invalidaddress could either be an address without an “@” in it, or an addresslist 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, itreturns a string that indicates the success or failure of theoperation. This string may be used verbatim by your program to reportthe outcome of send mail process. However, if you are embeddingSMTP.Server
for sending email through a WAP (Wireless Application Protocol) device (e.g., your mobile phones, Handheld PCs etc.) then you mustset this parameter to “1”. The reason is that the return message maycontain illegal characters like angled brackets “<” or “>”.Although an HTML page may overlook these, a WML browser gets confusedand tries to interpret it as a start/end of a WML tag, hence generatinga 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 theSendMail()
return string directly to a WAP device. See Example WML Code.Back to top
SendMail (strCc, strSubject, strMessage, strAttachFile)
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, Iwill implement this feature, at which time this parameter will take inthe attached file name. As of now, you may set it to an empty string orto any other value for that matter –SMTP.Server
simply ignores it.
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:
You can either pass on the Cc/Subject/Message information directly through the SendMail()
method call, oryou can set these individually by accessing the properties directly. Ifyou 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 willcontain “Message Successfully delivered”; else it will contain adescription of any error that might have occurred.
Back to top
Example Usage
- Example.asp (native ASP code)
- Example.wml (ASP code that incorporates WML)
- ServerTest.xls.
Send bugs/feedback/criticism to: kashifmanzoor@hotmail.com.
License
Thisarticle has no explicit license attached to it but may contain usageterms in the article text or the download files themselves. If in doubtplease contact the author via the discussion board below.
A list of licenses authors might use can be found here
About the Author
Kashif ManzoorI have 8 years of industry experience and am currently pursuing mygraduate studies at University of Illinois at Urbana Champaign.
Occupation: Web DeveloperLocation: United Kingdom
From: http://www.codeproject.com/KB/COM/smtp.aspx
- SMTP Client ActiveX component
- wod smtp activex
- component&Activex controls
- PDF Viewer Component ActiveX DoS
- SMTP Client with SSL/TLS
- c# smtp client 的应用
- Async Http Client (AHC) Component
- 20.12. smtplib — SMTP protocol client(SMTP 协议 客户端)
- Microsoft Access: ActiveX component cannot create object
- ActiveX component can't create object
- A Client to Send SMTP Mail
- ActiveX component can't create object这个错误怎么解决
- 执行StartExecution时, 报ActiveX component can't createobject错误
- Using Java to Develop a Very Simple SMTP Client
- ActiveX component can't create object(ActiveX 不能创建对象): 'TDApiOle80.TDConnection'
- EAServer Web Service Using PowerBuilder Component and Client
- Remoting from IIS Hosted component to ASP.NET Client application
- [原]client通过ActiveX与flash交互方法简介
- 123
- 100
- 关于shallow copy
- 我的CMS真的没有流量了吗?
- C++的new
- SMTP Client ActiveX component
- 什么是依赖注入
- Oracle Database(1)
- unix-center
- Use Deblector to debug application to get pseudo source debugging experience
- 关于依赖倒置,控制反转和依赖注入的趣谈
- 读取计算机的内存容量 (c#)
- ABCD*9=DCBA 那么A=? B=? C=? D=?
- java缓存问题