Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 29th, 2003, 12:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I tried that but it didn't work. What I ended up doing was finding the DNS of a valid SMTP server on the LAN here and used it instead of my test server.

 
Old October 30th, 2003, 10:27 PM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear all:

I have try to send an email by IIS Smtp Server, by this code:
SmtpMail.SmtpServer = "10.97.3.129"

But i have a big problem here, the IP Address on my PC is just temporary as it will be changed everytime i connect to the Internet(i use the prepaid Intenet Service)

So, i have tried to chage the code to:
SmtpMail.SmtpServer = "localhost" or
SmtpMail.SmtpServer = "myComputerName"

Although the message show that the email adready send, but i can't receive the mail anymore!

Pls kindly help me to solve the problem as this is my final year project!

Thanx for your solution!

Regards...

 
Old November 1st, 2003, 01:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

its a sample to friends, & hope will help u:
Code:
<%@ Page Language="VB" EnableSessionState="False" EnableViewState="False" Trace="False" Debug="False" Strict="True" %>
<%@ Import Namespace="System.Web.Mail" %> 

<script language="VB" runat=server> 

Sub Page_load(Sender as System.Object, e as System.EventArgs) 
  If Request.Form("EmailAddress") = "" Then
    lblMessage.Text = "<h4>Send Email using ASP.NET formatted in HTML</h4>"
  Else
    lblMessage.Text = "You just sent an email message formatted in HTML to:<br><h2>" & Request("EmailAddress") & "</h2>"
  End If
End Sub 

Sub btn_Click(Sender as Object, e as System.EventArgs)
  If Request.Form("EmailAddress") <> ""
    Dim mail As New MailMessage
    mail.From = "[email protected]"
    mail.To = Request.Form("EmailAddress")
    mail.Subject = "Message sent using ASP.NET and CDONTS"
    mail.Body = "HTML Message sent from ASPFree.com using ASP.NET and CDONTS<br><a href='http://aspfree.com/aspnet/email.aspx'>Wonder how this is done?</a><br><br><a href='http://aspfree.com/aspnet/setupcdonts.aspx'>Wonder How to setup CDONTS?</a>"
    mail.BodyFormat = MailFormat.Html
    SmtpMail.SmtpServer = "LocalServerName"
    SmtpMail.Send(mail)
  End If
End Sub

</script> 

<html>
<head>
</head>
<body>
<h1 align="center">Sending Email via ASP.NET</h1>
<br />
<asp:Label id="lblMessage" Font-Name="Verdana" Width="400px" BorderStyle="solid" BorderColor="#cccccc" runat="server"/>
<form method="post" name="form1" runat="server" runat="server">
Email Address:<input type="text" name="EmailAddress" size="30" value=""><br><br>
<input type="Submit" id="btnSubmit" OnServerClick="btn_Click" value="Sending Email with ASP.NET" name="b1" runat="server" />
</form>
</body>
</html>
Always:),
Hovik Melkomian.
 
Old November 3rd, 2003, 02:38 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Make sure your objMail.To = "" has a valid address in it. I use my own email when testing.

 
Old November 4th, 2003, 09:12 PM
Authorized User
 
Join Date: Nov 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Stu9820

I had trouble with the MailMessage at first, but here's some solutions:

                /* When sending mail be sure the moden is connected to the internet,
                 * and that the virus-checker is NOT checking outgoing mail.
                 * Then using "mailto:localhost" can be used but only seems to
                 * add another receipient. */
                MailMessage dealer_message = new MailMessage();
                dealer_message.To = "[email protected]";
                dealer_message.From = "[email protected]";
                dealer_message.Subject = "Testing Information";
                dealer_message.BodyFormat = MailFormat.Text;
                dealer_message.Body = "Request for Information from ";
                SmtpMail.SmtpServer = "mail.earthlink.net";
                SmtpMail.Send(dealer_message);

The SmtpServer address has to be the mail server of the location from which the e-mail is being sent.
My ISP is www.webhost4life.com, so I change it to the SmtpServer there:
SmtpMail.SmtpServer = "mail.webhost4life.com";
although the way they are set up that doesn't work as well as:
SmtpMail.SmtpServer = "xx.xxx.xxx.xxx"; // which is the IP of my site.

HtH



Sandra MacGregor
 
Old November 11th, 2003, 06:20 AM
Registered User
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear all,

How I can make a link to outlook express by clicking on the EMAIL column in the datagrid???
Before that, I used the code as below:
<A HREF="mailto:<%# DataBinder.Eval(Container.DataItem, "EMAIL") %>">
<%# DataBinder.Eval(Container.DataItem, "EMAIL") %></A>

But right now, I retrieved the data from database into datagrid using code behide. So, how I can make the link?

Any Idea?

Cheers,
bluemine11

 
Old November 11th, 2003, 08:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Dear frind:
ur script is not wronge!!! it'll work fine just ur defualt email software is not set to OutLook Express!

HTH.

PS: Since its not sending email from ASP.NET & u'd better to send new topic;)

Always:),
Hovik Melkomian.
 
Old December 3rd, 2003, 12:27 PM
Registered User
 
Join Date: Dec 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is possible to authenticate with the .Net MailMessage object. It is done through the Fields property:

Sample C# code:

//Use the following fields to add authentication, if necessary
//0 = None / 1 = Basic / 2 = NTLM
myMailMessage.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
myMailMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "myusername";
myMailMessage.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "mypassword";
 
Old October 1st, 2004, 07:39 AM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi All,
I am in a problem. The point is that I am trying to send mail from an ASP.Net webpage using the following code:

System.Web.Mail.MailMessage msg1 = new System.Web.Mail.MailMessage();
msg1.From = "[email protected]";
msg1.To = "[email protected]";
msg1.Subject = "Testing";
msg1.Body = "Hello";
System.Web.Mail.SmtpMail.SmtpServer = "localhost";
System.Web.Mail.SmtpMail.Send(msg1);

The smtp server on my local host is not configured to send emails. So I changed the "smart host" in advanced properties of IIS Local SMTP, I gave the server name of a machine which is on the LAN and is configured to send emails.

Now the error that I am getting is that:
The server rejected one or more recipient addresses. The server response was: 550 5.7.1

But the recipient address is absolutely right. There is nothing wrong in it. What should i do?

 
Old February 9th, 2007, 03:50 AM
Registered User
 
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi all This is my first post. For sending the mail i m using following code:
Sub SendMail()
        Dim sr As New StreamReader(Server.MapPath("slammail.htm"))
        Dim msgBody As String = sr.ReadToEnd
        sr.Close()
        msgBody = msgBody.Replace("Account_Username", txtUserName.Text)
        msgBody = msgBody.Replace("Account_UserPassword", txtPassword.Text)
        msgBody = msgBody.Replace("Account_SlamUrl", txtUserName.Text)

        Dim smtpServer As String = "webmail.xxx.com"
        Dim userName As String = "[email protected]"
        Dim password As String = "xxx"
        Dim cdoBasic As Integer = 1
        Dim cdoSendUsingPort As Integer = 2
        Dim objMail As New System.Web.Mail.MailMessage

        objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer)
        objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25)
        objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort)
        objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic)
        objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]")
        objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxx")
        'Dim objMail As New MailMessage
        objMail.To = txtEmail.Text
        objMail.From = """xxx""" & "xxx"""
        objMail.Subject = "Welcome to xxx"
        objMail.BodyFormat = MailFormat.Html
        objMail.Body = msgBody
        Try
            SmtpMail.SmtpServer = "localhost"
            SmtpMail.Send(objMail)
        Catch ex As Exception
            'SmtpMail.SmtpServer = "localhost"
            SmtpMail.Send(objMail)
        End Try
    End Sub

As this method required username password which is not always work when i work for my some client as they are not willing to give his password to me. Can somebody please tell some method of sending authenticate mail without the requirement of password.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending email in VB.net lowell .NET Framework 2.0 3 November 30th, 2008 11:51 AM
sending email from asp.net/sqlserver on a particul hepsy.i ASP.NET 1.0 and 1.1 Professional 1 July 11th, 2008 08:09 AM
How to Sending an email in asp.net 2.0 using C# Bashu C# 2005 4 August 14th, 2007 03:29 AM
sending email through asp.net [email protected] .NET Framework 1.x 2 October 19th, 2006 12:13 PM
Error in sending email from asp.net asif_sharif ASP.NET 1.0 and 1.1 Professional 4 January 7th, 2006 05:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.