Network Programming in .NET With C# and Visual Basic .NET phần 4

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@ | 149 --------- Figure 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@ to destination@ via the SMTP server change this to your own SMTP server . You must first make a reference to before you can import the namespace. This DLL is a .NET assembly not .COM. To do so click Project Add Reference and then click on the DLL Figure . 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 I Chapter 5 150 Imports Now click on the Send button and type in the following code C private void btnSend_Click object sender e MailMessage email new MailMessage email from .NET email Private Sub btnSend_Click ByVal sender As _ ByVal e As Handles Dim email As New MailMessage With email .From .To .Subject email from .NET .Body End With 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 .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
169    80    2    30-06-2024
Đã 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.