My OS is Windows XP. SMTP is not working. Virtual directory mail is coming. but mail is not going in smtp sever. i am using ASP & MS ACCESS. i have used one form. if i will click submit button that details r goto mail. plz help for this coding.
ASP send email
Collapse
X
-
-
Hello silvia21,
Give this a try. It has some error trapping that hopefully will give you some meaningful errors if any come up.
Hope this helps~
[CODE=asp]
<%
Set myMail=CreateOb ject("CDO.Messa ge")
myMail.Subject = "Hello"
myMail.From = "Bob@bob.co m"
myMail.To = "Sam@sam.co m"
myMail.TextBody = "Your message to Sam."
On Error Resume Next
myMail.Send
If Err <> 0 Then
Response.Write( "Error occurred: " & Err.Description )
else
Response.Write( "Your message was sent successfully.")
End If
Response.End
%>
[/CODE]Comment
-
In c#,
Add this namespaces
using System.Web.Mail ;
using System.Net.Mail ;
now,
SmtpClient objSmtpClient = new SmtpClient();
objSmtpClient .Send(txtFromAd dress.Text, txtToAddress.te xt, txtSubject.Text , txtBody.Text);
Before this you have to edit the web.config page in the system.net
there u have to mention your mail domain name and the port number
ex:
<system.net>
<mailSettings >
<smtp>
<network host="mail.XYZ. com" port="25" userName="Anyna me" password="asdkf hfffasf"/>
</smtp>
</mailSettings>
</system.net>Comment
-
for more knowledge go through these once ...............
Code:Sending a text e-mail: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.TextBody="This is a message." myMail.Send set myMail=nothing %> Sending a text e-mail with Bcc and CC fields: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.Bcc="someoneelse@somedomain.com" myMail.Cc="someoneelse2@somedomain.com" myMail.TextBody="This is a message." myMail.Send set myMail=nothing %> Sending an HTML e-mail: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.HTMLBody = "<h1>This is a message.</h1>" myMail.Send set myMail=nothing %> Sending an HTML e-mail that sends a webpage from a website: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.CreateMHTMLBody "http://www.w3schools.com/asp/" myMail.Send set myMail=nothing %> Sending an HTML e-mail that sends a webpage from a file on your computer: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.CreateMHTMLBody "file://c:/mydocuments/test.htm" myMail.Send set myMail=nothing %> Sending a text e-mail with an Attachment: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.TextBody="This is a message." myMail.AddAttachment "c:\mydocuments\test.txt" myMail.Send set myMail=nothing %> Sending a text e-mail using a remote server: <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.TextBody="This is a message." myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2 'Name or IP of remote SMTP server myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") _ ="smtp.server.com" 'Server port myMail.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _ =25 myMail.Configuration.Fields.Update myMail.Send set myMail=nothing %>
Thanks
Rahul.Comment
Comment