. Five different mail delivery solutions in the net environment

Source: Internet
Author: User
Tags mailmessage

This article describes the. NET environment, and the advantages and disadvantages of five different mail delivery solutions. Choose what program, depending on the application and requirements of the program, this article gives a few examples of programs for your reference.

1. Send with Outlook
For example: I have seen the Ufida U8 manufacturing (demo), where the mail function is by calling the Outlook ActiveX components
Advantages: Simple Development
Disadvantage: Dependent on Outlook components, SMTP Mail Service
The code to send the message is as follows:
The following is a reference fragment:
Private Sub Send ()
Dim Outobjas New Outlook.Application ()
Dim Item as Outlook.mailitemclass
Item = Outobj.createitem (0)
item.to = "Lihonggen0@163.com"
Item.Subject = "Hello"
Item.Body = "Hell"
ITEM.ATTACHMENTS.ADD ("C:abc.txt")
Item.Send ()
End Sub

2. Web development, referencing System.Web.Mail classes in asp.net

The System.Web.Mail namespace contains classes that enable you to construct and send messages using the CDOSYS (Windows 2000 Collaboration Data object) message component. Mail messages are delivered by means of an SMTP mail service or any SMTP server built into Microsoft Windows 2000. Classes in this namespace can be in asp.net or any managed application
MailAttachment provides properties and methods for constructing e-mail attachments.
MailMessage provides properties and methods for constructing e-mail messages.
SmtpMail provides properties and methods for sending messages using the Collaboration Data Object (CDOSYS) message component of Windows 2000.
Messages can be delivered through the SMTP mail service or any SMTP server that is built into Microsoft Windows 2000. Types in the System.Web.Mail namespace can be used in asp.net or in any managed application.
SMTP server settings, now some free mail providers are no longer providing SMTP service for all messages, when sending mail, need to authenticate user information, consider SMTP user authentication issues
If the SMTP server on the local computer, send fast, basically do not worry, if not the local server, then it is best not to send too much, one is the speed problem, the second is to send too many messages, the SMTP server may be considered spam and denial of service
The code is as follows:
The following is a reference fragment:
Private Sub button1_click (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Button1.Click
Dim Mailobjas New MailMessage ()
Dim Smtpas SmtpMail

' Define the name of the SMTP server
Smtp. SmtpServer = "SMTP. XXX.com "

' Define the sending address of the message
Mailobj.from = "Lihonggen@XXX.com"

' Define the receiving address of the message

mailobj.to = "AAA@XXX.com"
"Defines the message's dark-sent address

MAILOBJ.BCC = "Aa@sina.com"

' Define the CC address of the message
mailobj.cc = "Aaa@sina.com"

<

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.