A page for clients send mail to my email

Last post 05-20-2008 11:05 PM by Hong-Gang Chen - MSFT. 11 replies.

Sort Posts:

  • A page for clients send mail to my email

    05-16-2008, 10:42 AM
    • Loading...
    • smasher9
    • Joined on 05-14-2008, 1:41 PM
    • Posts 48

     I want to establish a contact page for clients send mail to my concrete email:Ex; webmaste@abc.edu

    in that page.have a textbox for user type their email:,textbox for title,textbox for body.and 1 button send.

    but i dont know how to solve this problem with i will use which SMTP server,port,.. .Because Their email is not concrete.(yahoo,gmail,,,,,)

    So How can i do? help me .thanks

    Mycode: 

     SmtpClient obj = new SmtpClient();
                MailMessage msg = new MailMessage();
                MailAddress mailadd = new MailAddress(this.Txt_EmailFrom.Text.ToString().Trim());
                msg.From = mailadd;
             
                msg.To.Add("webmaste@abc.edu");
                msg.BodyEncoding = System.Text.Encoding.UTF8;
                msg.IsBodyHtml = false;
                msg.Subject = this.Txt_Title.Text.Trim();
                msg.Body = this.Txt_Body.Text.Trim();
             
                //obj.Host = "localhost"  //Here i dont know ?which host i will use for my page? i used localhost,it cannot send mail.
                //obj.Port = 25;
                //obj.DeliveryMethod = SmtpDeliveryMethod.Network;
                obj.Send(msg);

  • Re: A page for clients send mail to my email

    05-16-2008, 10:48 AM

    obj.Host is your smtp server. You must have your own or a public server which provides sending mails over smtp. Port for smtp is normally 25! The deliverymethod you don't need. to send the mail. 

    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: A page for clients send mail to my email

    05-16-2008, 11:12 AM
    • Loading...
    • smasher9
    • Joined on 05-14-2008, 1:41 PM
    • Posts 48

     How can i try testing the function send mail while i dont have own server smtp to send over come all kind of email.?

  • Re: A page for clients send mail to my email

    05-16-2008, 10:49 PM
    • Loading...
    • smasher9
    • Joined on 05-14-2008, 1:41 PM
    • Posts 48

    Help me ! 

  • Re: A page for clients send mail to my email

    05-17-2008, 7:30 AM

    You could create a gmail testaccount because there you are able to send over their smtp server:

    http://lifehacker.com/software/email-apps/how-to-use-gmail-as-your-smtp-server-111166.php 

    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: A page for clients send mail to my email

    05-17-2008, 9:09 AM

    Hello Dear

    Try this out  

     

     Dim mailbody As String

            Dim c As New System.Net.Mail.SmtpClient("abc.com")
            Dim toMail As New MailAddress(emailVal)
            Dim FromMail As New MailAddress("emailId", "text")


            Dim m1 As New System.Net.Mail.MailMessage(FromMail, toMail)
            m1.Bcc.Add(FromMail)

            '---------------------------------------mail View-------------------------

            mailbody = "Mail body"



            '-------------------------------End Mail View ------------------------------------

            m1.IsBodyHtml = True
            m1.Body = mailbody
            m1.Subject = "Your Password"
            c.Send(m1)

    ======================================
    Regard,
    Pradeep Sahoo
    Sr. Sofware Developer
    Don't forget to click "Mark as Answer" on the post that helped you.
  • Re: A page for clients send mail to my email

    05-17-2008, 10:57 AM
    • Loading...
    • smasher9
    • Joined on 05-14-2008, 1:41 PM
    • Posts 48

    pradeepsahoo:

    Hello Dear

    Try this out  

     

     Dim mailbody As String

            Dim c As New System.Net.Mail.SmtpClient("abc.com")
            Dim toMail As New MailAddress(emailVal)
            Dim FromMail As New MailAddress("emailId", "text")


            Dim m1 As New System.Net.Mail.MailMessage(FromMail, toMail)
            m1.Bcc.Add(FromMail)

            '---------------------------------------mail View-------------------------

            mailbody = "Mail body"



            '-------------------------------End Mail View ------------------------------------

            m1.IsBodyHtml = True
            m1.Body = mailbody
            m1.Subject = "Your Password"
            c.Send(m1)

     

    I dont know you used which mailsever to send mail? 

    I wonder,how that code can send mail? 

  • Re: A page for clients send mail to my email

    05-19-2008, 12:51 AM

    Dim c As New System.Net.Mail.SmtpClient("abc.com")

     

    instread of abc.com --->>> you have to write mail server name......

    ======================================
    Regard,
    Pradeep Sahoo
    Sr. Sofware Developer
    Don't forget to click "Mark as Answer" on the post that helped you.
  • Re: A page for clients send mail to my email

    05-19-2008, 1:43 AM
    Answer

    hi ,

    You have configure your Smtp mail server first for your code to work.For that u have to open IIS and right click SMTP server select properties and enter the relevent ip address for the SMTP ip address and the port will be default 25.

    Now u can try your code by specifying the ip with the ip you have configured in the IIS. Surely mail will send to Gmail or Yahoo or another intranet ips..No issue with the id at all...You have to get your SMtp Server configured so that we can send mails.Thats it...As simple as that..Still u have doubt in configuring the SMTP Server perform a Google on that topic ..will od it for you.

    Cheers mate

    vijay Smile

     

    vijay
  • Re: A page for clients send mail to my email

    05-20-2008, 3:38 AM
    Answer

    Hi

    Try this

     

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Web.Mail;
    
    public partial class SendEmail : System.Web.UI.Page
    {
    string strMailOrTel;
    
    protected void Page_Load(object sender, EventArgs e)
    {
    
    }
    private bool SendMail()
    {
    try
    {
    string strTo = "your email";
    string strFrom = txtFrom.Text;
    string strBody = txtMessage.Text ;
    string strSubject = txtSubject.Text ;
    SmtpMail.SmtpServer = ("you smtp");
    SmtpMail.Send(strFrom, strTo, strSubject, strBody);
    
    return true;
    }
    catch (Exception ex)
    {
    return false;
    }
    }
    
    protected void btn_Send_Click(object sender, EventArgs e)
    {
    bool TrueOrFalse = SendMail();
    if ((TrueOrFalse == true))
    {
    Response.Redirect("~/MailSent.aspx");
    }
    else
    {
    Label1.Text = "Try again";
    }
    
    }
    
    
    }
    
     
    Regards,
    Yasser Zaid

    ~ Please remember to click Mark as Answer on this post if it helped you ~
  • Re: A page for clients send mail to my email

    05-20-2008, 1:34 PM
    • Loading...
    • smasher9
    • Joined on 05-14-2008, 1:41 PM
    • Posts 48

    thanks all ! But i only send mail by using Google mail server and my google mail account.I dont know use other method.because i dont know what is my smtp sever.:)
     

  • Re: A page for clients send mail to my email

    05-20-2008, 11:05 PM
    Answer

    smasher9:

    thanks all ! But i only send mail by using Google mail server and my google mail account.I dont know use other method.because i dont know what is my smtp sever.:)
     

    Hi smasher9,

    Please refer this thread,

    http://forums.asp.net/p/1167140/1944223.aspx

    and please attention more on the list reply of mine.

    Hope it helps,

    Hong Gang

    Sincerely,
    Hong Gang Chen
    Microsoft Online Community Support
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Page 1 of 1 (12 items)