Error sending through Exchange server


#1

EDIT: aMail (as referenced below) comes from the statement "Imports aMail = Aspose.Network.Mail"

Chances are I'm doing something wrong, so I thought you could tell me where. Smile [:)] I'm trying to connect to our exchange server and send out an email directly from there. I'm assuming by doing it this way, rather than using a virtual SMTP server to send the email, that the headers will look the same as if I had sent the message using Outlook. Please correct me if I am wrong. My code and the error I am receiving follows.

Dim myExchange As New aMail.MailExchangeConnection

myExchange.Host = "xxx.xxx.xxx.xxx"

myExchange.Username = "username"

myExchange.Password = "password"

Dim mySMTP As New aMail.SmtpClient(myExchange)

Dim myEmail As New aMail.MailMessage

myEmail.From = New aMail.MailAddress("from@from.com")

myEmail.To.Add(New aMail.MailAddress("to@to.com"))

myEmail.Subject = "Test email"

myEmail.Body = New aMail.TextPlainBody("this is a test")

mySMTP.Send(myEmail)

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   Aspose.Network.Mail.SmtpConnection.xe410125f7519de90() +437
   Aspose.Network.Mail.SmtpClient.x2de48dbd5ff873e9(MailMessage x1f25abf5fb75e795, SmtpConnection x7316af229433e69e) +421
   Aspose.Network.Mail.SmtpClient.Send(MailMessage message) +24

#2

Hi, dthayer,

In order to create MailExchangeConnection, we should provide the domain name to resolve the address of the mail exchange server. As following:

Dim myExchange As New MailExchangeConnection("microsoft.com");

...

Thanks


#3

Ok, if that is the case, how am I suppose to test the Mail product before purchasing it, since the evaluation is limited to 11 character domains? That will exclude a lot of them, including ours. I understand that you have to place some limitations on it in order to keep people from abusing the evaluation copy, but why not insert random characters into the subject and or body of the email, or add your "This is an evaluation" message to the subject and/or body instead? Just a suggestion, because I won't be able to actually test the Mail product before buying it if I can't enter more than 11 characters in the domain field.

Dan


#4

if you know the host of the mail exchange server, please use another contructor to create the connection class

Dim myExchange as New MailExchangeConnection(new string (){"exchange.microsoft.com"})

our developer will provide you another dll for your demoing later the day.

Thanks


#5

Hi, Dan,

What's your email ? I will send you another version of Aspose.Network for your demoing. Could you send to my email guangzhou #aspose.com?

Thanks very much.