G
Guest
OK, I am getting really frustrated with this. I need to be able to send email
using smtp. The server that we are using is hosted by a third party. We have
created a new account with username and password.
I have searched high and low for a solution to my problem. I have
implemented what I have found but I still get the same error:
"System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.Runtime.InteropServices.COMException
(0x80040220): The "SendUsing" configuration value is invalid.
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object obj,
String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TheColeGroup.Mail.btnSend_Click(Object sender, EventArgs e) in
D:\Projects\Cole Group\TheColeGroupWeb\Mail.aspx.vb:line 106"
Here is the code that I am using:
<code>
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSend.Click
Dim objMail As New MailMessage
lSuccess =
False
Try
If System.IO.File.Exists(Me.txtAttachment.Text) Then
objMail.To =
Me.txtTo.Text
objMail.From = "(e-mail address removed);" &
Me.txtFrom.Text
objMail.Cc =
Me.txtCC.Text
objMail.BodyFormat = MailFormat.Text
objMail.Subject =
Me.txtSubject.Text
objMail.Body =
Me.txtBody.Text
objMail.Attachments.Add(
New MailAttachment(Me.txtAttachment.Text, MailEncoding.Base64))
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
'basic authentication
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username")
'set your username here
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password")
'set your password here
SmtpMail.SmtpServer.Insert(0, "smtp.mysite.com")
'SmtpMail.SmtpServer.Insert(0, "smtp_auth.mysite.com")
SmtpMail.Send(objMail)
lSuccess =
True
End If
Catch ex As Exception
sMessage = ex.ToString
End Try
End Sub</code>
Can anyone please HELP ME!?
Thanks,
enak
using smtp. The server that we are using is hosted by a third party. We have
created a new account with username and password.
I have searched high and low for a solution to my problem. I have
implemented what I have found but I still get the same error:
"System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.Runtime.InteropServices.COMException
(0x80040220): The "SendUsing" configuration value is invalid.
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder
binder, Object target, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object obj,
String methodName, Object[] args)
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
--- End of inner exception stack trace ---
at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at TheColeGroup.Mail.btnSend_Click(Object sender, EventArgs e) in
D:\Projects\Cole Group\TheColeGroupWeb\Mail.aspx.vb:line 106"
Here is the code that I am using:
<code>
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSend.Click
Dim objMail As New MailMessage
lSuccess =
False
Try
If System.IO.File.Exists(Me.txtAttachment.Text) Then
objMail.To =
Me.txtTo.Text
objMail.From = "(e-mail address removed);" &
Me.txtFrom.Text
objMail.Cc =
Me.txtCC.Text
objMail.BodyFormat = MailFormat.Text
objMail.Subject =
Me.txtSubject.Text
objMail.Body =
Me.txtBody.Text
objMail.Attachments.Add(
New MailAttachment(Me.txtAttachment.Text, MailEncoding.Base64))
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
'basic authentication
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username")
'set your username here
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password")
'set your password here
SmtpMail.SmtpServer.Insert(0, "smtp.mysite.com")
'SmtpMail.SmtpServer.Insert(0, "smtp_auth.mysite.com")
SmtpMail.Send(objMail)
lSuccess =
True
End If
Catch ex As Exception
sMessage = ex.ToString
End Try
End Sub</code>
Can anyone please HELP ME!?
Thanks,
enak