Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello every one.
i want to add a mail box in my web site in which i am able to send mail and receive mail with in my website. means mail can only be send to members of my website not to gmail, yahoo hotmail etc...

plz help to do this from scrap....... thanks
Bilal Hassan
Posted
Updated 17-Jun-11 6:21am
v2

Recently I have implemented same. Please follow below step:

1. Create Table and field would be:
MailMessage (Table)
   MessageId (PK)
   SenderUserId
   RecieverUserId
   Subject
   Message
   IsRead (To view read/unread mail)
   DeletedBySender
   DeletedByReciever
   ArchiveBySender
   ArchiveByReciever
   MessageOn (DateTime)   


2. For Inbox: Your query will fetch info based on RecieverUserId
3. For SendItem: Your query will fetch info based on SenderUserId

Hope so will help you!

Thanks
 
Share this answer
 
Comments
Anupama Roy 17-Jun-11 12:36pm    
Good One!
Parwej Ahamad 17-Jun-11 12:42pm    
Thanks Anupama
bilal _hassan 17-Jun-11 13:08pm    
hmmm thanks but i want little more help regarding coding as i am a student.... if possible....
Parwej Ahamad 17-Jun-11 13:13pm    
Dear If I will write the code then it's doesn't help you in future. So first try to implement by your self. f you are facing any logical/functional issue then I will help you and will write code for you.

Thanks
bilal _hassan 17-Jun-11 13:29pm    
okayssssssss thanks i will try by muself and then let u know my progress.
once again thanks alot.....
you can also try this[^]

hope this helps :)
 
Share this answer
 
Create FindEmailAddress() function for retrive email using SQL from DataBase.

Then add below code on send button click.


{
       {
          MailAddress mailTo = new MailAddress(FindEmailAddress());
          MailAddress MailCC = new MailAddress("example@abc.com");
          MailAddress mailFrom = new MailAddress(ConfigurationSettings.AppSettings["EmailFrom"].ToString());
          MailMessage MailObject = new MailMessage(mailFrom, mailTo);
          MailObject.CC.Add(MailCC);
          MailObject.Subject = "Type your Subject here";
          string s = Request.Url.AbsoluteUri;
          string ErrorHandling_Message = "Type your Message here";
          try
          {
              MailObject.Body = ErrorHandling_Message;
              MailObject.IsBodyHtml = true;
              SmtpClient smtp = new SmtpClient();
              smtp.Host = "mail.google.com";
              smtp.Credentials = new System.Net.NetworkCredential(ConfigurationSettings.AppSettings["EmailFrom"].ToString(), ConfigurationSettings.AppSettings["Password"].ToString()); ;
              smtp.EnableSsl = false;
              smtp.Send(MailObject);
              return true;
          }

          catch (Exception ex)
          {

              return false;
          }
      }
      return false;
  }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900