Smtp.NET 3 Documentation

SmtpServer.BodyUrl Property

Specifies a URL to load the body of the message from.

[Visual Basic]
Public Property BodyUrl As String
[C#]
public string BodyUrl {get; set;}

Property Value

A string that is a URL to load the body of the message from.

Remarks

This property must be set to a valid URL that is of protocol "http://". Limitations:

  1. "You cannot use the "file:" protocol.
  2. The content type is always set to TEXT/HTML.
  3. Shockwave files are not guaranteed to be viewable in the client browser.
  4. Urls that redirect to another directory or site may cause broken images. Be sure to not specify URLs that may redirect.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();
             
                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";
                  
                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";
             
                 // Set the subject 
                 oSmtpDotNet.Subject = "Routine email";
                  
                 // Set the message body to the contents (html) found
                 // at http://www.ExclamationSoft.com
                 oSmtpDotNet.BodyUrl = "http://www.ExclamationSoft.com";
            
                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }
             
                 // Success!
                 Console.WriteLine("Success!");
            }
            
[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes
            
                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"
                 
                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"
            
                 ' Set the subject 
                 oSmtpDotNet.Subject = "Routine email"
                  
                 ' Set the message body to the contents (html) found
                 ' at http://www.ExclamationSoft.com
                 oSmtpDotNet.BodyUrl = "http://www.ExclamationSoft.com"
            
                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If
            
                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function
            

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace