Click here to Skip to main content
15,908,931 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionProblem in postback after populating dropdown using clientside script Pin
CrazyCoder2619-Jun-09 0:50
CrazyCoder2619-Jun-09 0:50 
AnswerRe: Problem in postback after populating dropdown using clientside script Pin
Aman Bhullar19-Jun-09 1:01
Aman Bhullar19-Jun-09 1:01 
GeneralRe: Problem in postback after populating dropdown using clientside script Pin
CrazyCoder2619-Jun-09 1:10
CrazyCoder2619-Jun-09 1:10 
GeneralRe: Problem in postback after populating dropdown using clientside script Pin
CrazyCoder2619-Jun-09 1:12
CrazyCoder2619-Jun-09 1:12 
QuestionCookie problem in asp.net Pin
Amit Patel198519-Jun-09 0:05
Amit Patel198519-Jun-09 0:05 
AnswerRe: Cookie problem in asp.net Pin
Manas Bhardwaj19-Jun-09 0:12
professionalManas Bhardwaj19-Jun-09 0:12 
QuestionRe: Cookie problem in asp.net Pin
Amit Patel198519-Jun-09 4:38
Amit Patel198519-Jun-09 4:38 
QuestionProblem sending an E-mail Pin
Vimalsoft(Pty) Ltd18-Jun-09 23:25
professionalVimalsoft(Pty) Ltd18-Jun-09 23:25 
Good Morning All

I have the Following code that sends an e-mail, let me first post the markup and the code behind. The following is the markup of my page

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        To &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<asp:TextBox ID="txtto" runat="server" Width="325px"></asp:TextBox><br />
        <br />
        From &nbsp;&nbsp; &nbsp;<asp:TextBox ID="txtFrom" runat="server" Width="326px"></asp:TextBox><br />
        &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
        <br />
        CC: &nbsp; &nbsp;&nbsp; &nbsp;<asp:TextBox ID="txtcc" runat="server" Width="326px"></asp:TextBox><br />
        <br />
        Subject:
        <asp:TextBox ID="txtsubject" runat="server" Width="326px"></asp:TextBox><br />
        Body :<br />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;
        <asp:TextBox ID="txtbody" runat="server" Height="86px" Width="314px"></asp:TextBox><br />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
        Port: &nbsp; &nbsp; &nbsp; &nbsp;
        <asp:TextBox ID="txtport" runat="server" Width="127px"></asp:TextBox><br />
        &nbsp;<br />
        Host &nbsp; &nbsp; &nbsp; &nbsp;
        <asp:TextBox ID="txthost" runat="server" Width="127px"></asp:TextBox><br />
        <br />
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<asp:Button ID="btnSend" runat="server"
            OnClick="btnSend_Click" Text="Send" />
        <asp:Button ID="btnCancel" runat="server" Text="Cancel" /><br />
        <br />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>
    </form>
</body>
</html>


and i have a Function that sends the e-mail like this

private static string SendEmail(String from, string to, string cc,int port, string subject, string message,String Host)
    {
        //create the mail message
        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
        //set the content
        mail.From = new System.Net.Mail.MailAddress(from,"Test E-mail");

        mail.Subject = subject;

        mail.Body = message;
        
        mail.IsBodyHtml = false;
        
        
        //send the message
        //SmtpClient smtp = new SmtpClient("196.35.193.28");     // use this Smtp Server
        // seems we can use either the big routing server or our own ip address
        System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
       
        smtp.Port = port;
        
        smtp.Host = Host;
         //mailSenderInstance.Credentials = New System.Net.NetworkCredential("LoginAccout", "Password") 
        smtp.Credentials = new System.Net.NetworkCredential("administrator", "skskssk");
 
        try
        {
            smtp.Send(mail);
            return "Mail sent successfully!";
        }
        catch (Exception ex)
        {
            Exception ex2 = ex;
        
            string errorMessage = string.Empty;

            while (ex2 != null)
            {
                errorMessage += ex2.ToString();
            
                ex2 = ex2.InnerException;
            }

            return errorMessage;
        }
        // Mailbox unavailable. The server response was 5.7.1. Unable to relay for (name).
        // see notes under Techdocs
        //client.Host = "localhost";  // setup the server / host sending the mail
        // client.UseDefaultCredentials = true;

    }


and in my button send we have the following

protected void btnSend_Click(object sender, EventArgs e)
   {
      Label1.Text =  SendEmail(txtFrom.Text, txtto.Text, txtcc.Text, Convert.ToInt32(txtport.Text), txtsubject.Text,txtbody.Text,txthost.Text);

   }



I have entered the Following in the Required Fields when i test the application

To: Vuyiswa@its.co.za

From:Vuyiswa@its.co.za

CC:vuyiswamb@gmail.com
Subject: This is the Test for the mail in o!booking System
BodyIf you Receive this e-mail Please confirm the receipt of this e-mail
Port : 25
Host:  mailserver.Vuyiswa.local


When i run my Application and clicking on the send button , i get the Following Error


System.InvalidOperationException: A recipient must be specified. at System.Net.Mail.SmtpClient.Send(MailMessage message) at _Default.SendEmail(String from, String to, String cc, Int32 port, String subject, String message, String Host) in c:\Vuyiswa\Email_test\Default.aspx.cs:line 51


Thanks

Vuyiswa Maseko,

Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/

AnswerRe: Problem sending an E-mail Pin
himanshu256118-Jun-09 23:34
himanshu256118-Jun-09 23:34 
GeneralRe: Problem sending an E-mail Pin
Vimalsoft(Pty) Ltd18-Jun-09 23:46
professionalVimalsoft(Pty) Ltd18-Jun-09 23:46 
GeneralRe: Problem sending an E-mail Pin
Christian Graus18-Jun-09 23:48
protectorChristian Graus18-Jun-09 23:48 
GeneralRe: Problem sending an E-mail Pin
Vimalsoft(Pty) Ltd19-Jun-09 0:01
professionalVimalsoft(Pty) Ltd19-Jun-09 0:01 
GeneralRe: Problem sending an E-mail Pin
Christian Graus19-Jun-09 11:18
protectorChristian Graus19-Jun-09 11:18 
GeneralRe: Problem sending an E-mail Pin
Vimalsoft(Pty) Ltd21-Jun-09 20:16
professionalVimalsoft(Pty) Ltd21-Jun-09 20:16 
QuestionPopulating dropdownlist with javascript [modified] Pin
CrazyCoder2618-Jun-09 23:22
CrazyCoder2618-Jun-09 23:22 
AnswerRe: Populating dropdownlist with javascript Pin
himanshu256118-Jun-09 23:43
himanshu256118-Jun-09 23:43 
GeneralRe: Populating dropdownlist with javascript Pin
CrazyCoder2619-Jun-09 0:09
CrazyCoder2619-Jun-09 0:09 
QuestionHelp to sepration in checkListBox? [modified] Pin
kripa2118-Jun-09 23:18
kripa2118-Jun-09 23:18 
AnswerRe: Help to sepration in checkListBox? Pin
Herman<T>.Instance19-Jun-09 1:21
Herman<T>.Instance19-Jun-09 1:21 
GeneralRe: Help to sepration in checkListBox? Pin
kripa2119-Jun-09 2:26
kripa2119-Jun-09 2:26 
GeneralRe: Help to sepration in checkListBox? Pin
kripa2123-Jun-09 0:08
kripa2123-Jun-09 0:08 
Questiongridview Pin
vikas shukla18-Jun-09 22:07
vikas shukla18-Jun-09 22:07 
AnswerRe: gridview Pin
Christian Graus18-Jun-09 22:37
protectorChristian Graus18-Jun-09 22:37 
Questionplease tell me Pin
sivasampathkumar18-Jun-09 22:01
sivasampathkumar18-Jun-09 22:01 
AnswerRe: please tell me Pin
dan!sh 18-Jun-09 22:08
professional dan!sh 18-Jun-09 22:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.