Send mail Author:david Euler
Date:2004/11/18
email:de_euler-david@yahoo.com.cn
Have any questions, please contact me:
Always want to do to implement a program, regularly to send their own mail, or to friends to send messages, such as in the holiday or commemorate a few days ago, send a message to their own reminders, or friends birthday to send e-mail reminders. Looking for a long time, did not find the available information.
CSDN found that CDO could be used, and an article said, "Add CDO for Windows 2000 in reference," and then look for it in the reference, and not find a component that begins with a CDO, and look at the list of COM components that can be referenced in the afternoon. We found a COM component named Microsoft CDO for Exchange Library, which we can use to connect to SMTP Server and send mail using username/password Authentication.
Here is an example of an implementation:
SMTP server uses SMTP-SRV, login username is David Euler, send mailbox is davidEuler@test.com, send to test@test.com/
1. Within the Explorer, add a reference (reference) to add the COM component of the Microsoft CDO for Exchange Library;
2). Edit the user interface as shown above, add Fromtextbox,totextbox,cctextbox,bcctextbox,subjecttextbox,messagetextbox,passwordtextbox in turn, Smtptextbox, set Messagetextbox TextMode property to "MultiLine", Passwordtextbox TextMode property is "Password" and add a response prompt label to add send button.
3. After entering the username, password, SMTP server, the user clicks the Send button to send the message,
The Click event code for the Send button is as follows:
Cdos. Message omsg = new CDO. Message ();
oMsg.From = Fromtextbox.text;
oMsg.To = Totextbox.text;
oMsg.Subject = Subjecttextbox.text;
Omsg.textbody = Messagetextbox.text;
Omsg.cc=cctextbox.text;
Omsg.bcc=bcctextbox.text;
String UserName;
String Emailfrom;
String password=passwordtextbox.text.tostring (). Trim ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.