aspNetEmail

EmailMessage.Connect Method 

Open's the mail server network connection.

public void Connect();

Remarks

This method can be used for manually opening the SMTP connection, sending numerous emails, and then closing the SMTP connection by calling .Disconnect()

Example

[C#]
            EmailMessage msg = new EmailMessage( "mail.myCompany.com");
            msg.FromAddress = "me@myCompany.com";
            msg.To = "You@YourCompany.com";
            
            //connect to the mail server
            msg.Connect();
            
            //send the email messages,without disconnecting
            for( int i=0;i<10;i++)
            {
            	//reset any email properties
            	//msg.To = ...
            	//msg.Subject = ....
            	//msg.Body = ...
            
            	//as an example, number the subject and body
            	msg.Subject = "email number " + i.ToString();
            	msg.Body = "these are the email contents for number " + i.ToString();
            
            	msg.Send( false, false );
            }
            
            //disconnect from the mail server
            msg.Disconnect();
            
            
[VB.NET]
            Dim msg As New EmailMessage("mail.myCompany.com")
            
            msg.FromAddress = "me@myCompany.com"
            msg.To = "You@YourCompany.com"
            
            'connect to the mail server
            msg.Connect()
            
            'send the email messages,without disconnecting
            Dim i As Integer
            For i = 0 To 9
               'reset any email properties
               'msg.To = ...
               'msg.Subject = ....
               'msg.Body = ...
               'as an example, number the subject and body
               msg.Subject = "email number " + i.ToString()
               msg.Body = "these are the email contents for number " + i.ToString()
               
               msg.Send(False, False)
            Next i
            
            'disconnect from the mail server
            msg.Disconnect()
            
            

See Also

EmailMessage Class | aspNetEmail Namespace