ASP. NET forums email sending

Source: Internet
Author: User
Original article: http://blog.joycode.com/dotey/archive/2005/01/15/43113.aspx

ASP. NET forums email sending

In forums, email sending is required in many places, such as email registration, password retrieval, and email subscription.

Add a new postCodeThe process is very slow. Each time a post is added, the applicationProgramFirst, make sure that there are no repeated posts, format the post content and emoticon images, Mark and index them. If necessary, add the post to the corresponding queue to check the attachment validity, after the post is finally sent, an email notification will be sent to the subscription user. Obviously, too much work is done here. Indexing a post is a very time-consuming operation. In addition, the built-in system. Web. Mail function must be connected to the SMTP server and send emails in sequence. When the number of subscribers for a specific post or topic increases, the execution time of the post will grow.

Not every request requires indexing emails. Therefore, forums adopts centralized batch processing and only indexes 25 posts at a time or sends emails every five minutes. The timer part describes the timer application in Asp.net forums in my previous blog.

In ASP. NET, mail sending is very easy. Generally, SMTP servers are required, but some SMTP servers (such as smtp.163.com) in free mailboxes require account and password verification. Add the following content to the filds set of the mailmessage object:

Message. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1 ");
// Basic Authentication
Message. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendusername", txtusername. Text );
// Set the SMTP server Logon account (for example, your 163.com mailbox account)
Message. Fields. Add ("http://schemas.microsoft.com/cdo/configuration/sendpassword", txtpassword. Text );
// Set the SMTP server logon password (for example, your 163.com mailbox account password)

However, you must pay attention to one problem when using the free SMTP server, that is, the account that sends the email (that is, the message. from) must be the same as the account used to log on to the SMTP server. Otherwise, the CDO object cannot be found.

Sample Code:
Sample email sending code

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.