jonah_taxt
August 30th, 2004, 07:04 PM
Hi everyone. I'm trying to send an email with my application. Here's the code:
Try
Dim mensaje As New Mail.MailMessage
Dim smtpmail As Mail.SmtpMail
If Not Session("fn") Is Nothing Then
Dim oAttach = (Server.MapPath(Request.ApplicationPath) & "\Folder\(" & Session("Cot_Num") & ")" & Session("fn"))
mensaje.Attachments.Add(oAttach)
End If
mensaje.To = ClientMail
mensaje.From = AdminMail
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/smtsperver") = MailServer
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = AdminMail
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = PassAdminMail
mensaje.Subject = "Some text" mensaje.BodyFormat = Mail.MailFormat.Text
mensaje.Body = "Some text"
smtpmail.SmtpServer = MailServer
smtpmail.Send(mensaje)
mensaje = Nothing
Response.Redirect("/sent.aspx", False)
Catch ex As Exception
Response.Write("Error: " & ex.Message)
End Try
the "specified cast not valid error" happens when the debugger gets to smtpmail.Send(mensaje)
Could somebody help me?
Thanx for any replies :)
Try
Dim mensaje As New Mail.MailMessage
Dim smtpmail As Mail.SmtpMail
If Not Session("fn") Is Nothing Then
Dim oAttach = (Server.MapPath(Request.ApplicationPath) & "\Folder\(" & Session("Cot_Num") & ")" & Session("fn"))
mensaje.Attachments.Add(oAttach)
End If
mensaje.To = ClientMail
mensaje.From = AdminMail
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/smtsperver") = MailServer
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = AdminMail
mensaje.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = PassAdminMail
mensaje.Subject = "Some text" mensaje.BodyFormat = Mail.MailFormat.Text
mensaje.Body = "Some text"
smtpmail.SmtpServer = MailServer
smtpmail.Send(mensaje)
mensaje = Nothing
Response.Redirect("/sent.aspx", False)
Catch ex As Exception
Response.Write("Error: " & ex.Message)
End Try
the "specified cast not valid error" happens when the debugger gets to smtpmail.Send(mensaje)
Could somebody help me?
Thanx for any replies :)