Problem with running sample code


#1

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("sender@aspose.com")

I ran the installer and made a reference ...


#2

Please check out the attached document.

Thanks


#3

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


#4

Check this out.

Thanks


#5

This is the output …


#6

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


#7

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("guangzhou@aspose.com")

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

'receipients

msg.To.Add(New Aspose.Network.Mail.MailAddress("kyle.huang@aspose.com"))
msg.To.Add(New Aspose.Network.Mail.MailAddress("dean.deng@aspose.com"))

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("mail.aspose.com")
client.Port = 25
client.Username = "user"
client.Password = "password"

Creat a SmtpClient instance to connect to your mail server, send the message
Try
'send this message
client.Send(msg)
Catch e As Exception
Console.WriteLine(e)
End Try
Console.Read()

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

Thanks


#8

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


#9

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:

http://www.aspose.com/Downloads/Aspose.Network/3.1.0.0/Default.aspx