Problem with running sample code


When running the sample mailconsoledemovb the following exception occurs:-

An unhandled exception of type 'System.NullReferenceException' occurred in MailConsoleDemoVB.exe

Additional information: Object reference not set to an instance of an object.

At this statement:

msg.From = New Aspose.Network.Mail.MailAddress("")

I ran the installer and made a reference ...


Please check out the attached document.



Hi, I'm using VS2003. Asp/net 1.1. My version does not accept this solution: complaints about a higher version.


Check this out.



This is the output …


Oh, Sorry, I made a mistakes to send you the wrong file.


Dissection of attached sample code

Dim msg As New Aspose.Network.Mail.MailMessage

We first create a MailMessage instance, which is the container holding the messages or files to send by the SmtpClient

msg.From = New Aspose.Network.Mail.MailAddress("")

Set the From email address, let's say the sender of the message

msg.Subject = "hello"

Set the Subject of the message
'email bodies
msg.TextBody = "Please open this mail message by browser"

Set the TextBody of the message, if the mail client of receipients can not read html message, use the TextBody
msg.HtmlBody = "this is a html body"

Set the HtmlBody of the message


msg.To.Add(New Aspose.Network.Mail.MailAddress(""))
msg.To.Add(New Aspose.Network.Mail.MailAddress(""))

Set receipients' email address

'attached a local file to the mail
'msg.Attachments.Add(New Aspose.Network.Mail.Attachment("..\..\Module1.vb"))

Add attachement to the mail

'send mail by SmtpClient
Dim client As Aspose.Network.Mail.SmtpClient = New SmtpClient("")
client.Port = 25
client.Username = "user"
client.Password = "password"

Creat a SmtpClient instance to connect to your mail server, send the message
'send this message
Catch e As Exception
End Try

Feel free to ping me with any problems. We are glad to provide any help or demonstrations if you need.



This one works. In what respect does it differ from the delivered examples ?


The previous failed demo does not set the receiptient address.

We have updated the setup package.

  • New demo for pop3/Imap is included.
  • Hotfix for reading Outlook Message.

Check it out: