Wednesday, March 28, 2012

smtp mail ?? really need help....

Edited by SomeNewKid. Please post code between<code> and</code> tags.



hi!
i tried to write coding to send an email through smtp using asp.net , i get an error message which says : "Could not access 'CDO.Message' object. "
below is the code i wrote in VB language :

-----------------------------------

Imports System.Web.Mail
Public Class _default
Inherits System.Web.UI.Page
Protected WithEvents BSend As System.Web.UI.WebControls.Button
Private Sub BSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BSend.Click
Dim mailMessage As MailMessage
mailMessage = New MailMessage()
mailMessage.From = "me@dotnet.itags.org.trial.com"
mailMessage.To = "coba@dotnet.itags.org.cobacoba.com"
mailMessage.Subject = "Test subject"
mailMessage.BodyFormat = MailFormat.Text
mailMessage.Body = "Testing email "
System.Web.Mail.SmtpMail.SmtpServer = "localhost"
Try
SmtpMail.Send(mailMessage)
Response.Write("Message sent!")
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
End Class
------------------------------------

i don't know why the error keep occuring. I have set the control panel>administrative tools>iis>default smtp virtual server>properties>access>connection>add with : 127.0.0.1, and the same thing goes for the relay. My server is called "localhost". Could someone please tell me why the error keep occuring??Hello, check this code to send an email from ASP.NET:
Send Email with ASP.NET

regards.

0 comments:

Post a Comment