R
RedEye
Hello,
I am trying to create a class to send email via POP3 or Exchange.
Everything works fine when sending via POP3 but fails when sending via
exchange.
Error: Could not access 'CDO.Message' object.
The following code works fine in a VB.Net test app but fails on the web.
Does anyone have an idea why??
'--------------------------------------------------------------------
Dim mMail As New mail.MailMessage
Dim smtp as mail.SmtpMail
With mMail
.From = _addressFrom
.To = _sendTo
.Cc = _CC
.Subject = _subject
.Body = _body
.BodyFormat = _format
End With
' Check if the server type is POP3 or MS Exchange
If _mailServerType = ServerType.POP3 Then
smtp.SmtpServer = _smtpHost
Else
' The following code is need to authenticate to a exchange server
' Where the 2 specifies NTLM, 1 for basic, 0 for none (the default)
Dim userid As String = String.Format("{0}\{1}", _domain, _mailbox)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthent
icate", 2)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusernam
e", userid)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpasswor
d", _password)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver"
, _smtpHost)
End If
smtp.Send(mMail)
'--------------------------------------------------------------------
Thanks,
RedEye
I am trying to create a class to send email via POP3 or Exchange.
Everything works fine when sending via POP3 but fails when sending via
exchange.
Error: Could not access 'CDO.Message' object.
The following code works fine in a VB.Net test app but fails on the web.
Does anyone have an idea why??
'--------------------------------------------------------------------
Dim mMail As New mail.MailMessage
Dim smtp as mail.SmtpMail
With mMail
.From = _addressFrom
.To = _sendTo
.Cc = _CC
.Subject = _subject
.Body = _body
.BodyFormat = _format
End With
' Check if the server type is POP3 or MS Exchange
If _mailServerType = ServerType.POP3 Then
smtp.SmtpServer = _smtpHost
Else
' The following code is need to authenticate to a exchange server
' Where the 2 specifies NTLM, 1 for basic, 0 for none (the default)
Dim userid As String = String.Format("{0}\{1}", _domain, _mailbox)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthent
icate", 2)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusernam
e", userid)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpasswor
d", _password)
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver"
, _smtpHost)
End If
smtp.Send(mMail)
'--------------------------------------------------------------------
Thanks,
RedEye