Đang chuẩn bị liên kết để tải về tài liệu:
Network Programming in .NET With C# and Visual Basic .NET phần 4

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Nó đơn giản hơn nhiều so với thực hiện SMTP, đặc biệt là ở file đính kèm và giàu văn bản email tham gia, tuy nhiên, CDOSYS chỉ có thể cung cấp chức năng cho các mặt hàng của dịch vụ email. Ví dụ sau đây cho thấy làm thế nào để gửi một email đơn giản từ source@here.com | 5.5 System.Web.Mail 149 --------- Figure 5.4 Visual Studio .NET Add Reference. dows 2000 . It is much simpler than implementing SMTP especially where attachments and rich-text emails are involved however CDOSYS can only provide functionality for the client side of the email service. The following example shows how to send a simple email from source@here.com to destination@there.com via the SMTP server smtp.ntl-world.com change this to your own SMTP server . You must first make a reference to System.Web.dll before you can import the System.Web.Mail namespace. This DLL is a .NET assembly not .COM. To do so click Project Add Reference and then click on the DLL Figure 5.4 . With that you can draw your GUI. Drag three textboxes onto the form name them tbTo tbFrom and tbServer. Drag another textbox onto the form name it tbMessage and set multiline to true. Finally place a button on the form and name it btnSend. C using System.Web.Mail I Chapter 5 150 5.5 System.Web.Mail VB.NET Imports System.Web.Mail Now click on the Send button and type in the following code C private void btnSend_Click object sender System.EventArgs e MailMessage email new MailMessage email.From tbFrom.Text email.To tbTo.Text email.Subject email from .NET email.Body tbMessage.Text SmtpMail.SmtpServer tbServer.Text SmtpMail.Send email VB.NET Private Sub btnSend_Click ByVal sender As System.Object _ ByVal e As System.EventArgs Handles btnSend.Click Dim email As New MailMessage With email .From tbFrom.Text .To tbTo.Text .Subject email from .NET .Body tbMessage.Text End With SmtpMail.SmtpServer tbServer.Text SmtpMail.Send email End Sub This code simply sets the various properties of a MailMessage object and passes it to the SmtpMail object. To test the application run it from Visual Studio .NET. Fill in your own email address in the To field your SMTP server in the Server field and then fill in whatever you wish in the .

TÀI LIỆU LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.