Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
3.67/5 (3 votes)
See more:
Hi all,

i have a code written for Send mail in asp.ent. This is just so that two users can communicate
C#
protected void Button1_Click(object sender, EventArgs e)
    {
        SmtpClient client = new SmtpClient["smtpserver.company.com",25);
        client.Credentials = new NetworkCredential["user@xyz.com",Password);
        MailMessage msg = new MailMessage();
        msg.From = new MailAddress(TxtFrom.Text);
        msg.To.Add(new MailAddress(TxtTO.Text);
        msg.Subject = TxtSubject.Text;
        msg.Body = TxtDesc.Text;
       
       try
       {
           client.Send(msg);
       }
       catch(Exception ex)
       {
        Label5.Text = "Unable to show message";   
       }

    }
}

This is the code I used for Send functionality

Now How should I do the "Save to draft". Should I be saving it to a databse
What are the required things to be considered in Save to Draft

I am a beginner, so pls pardon my naive questions

Thanks
smitha
Posted
Updated 7-Feb-11 20:02pm
v2
Comments
Member 10762640 21-Apr-14 21:46pm    
code for the how save the send mails in sent box?

Save to "Draft" could be saved to a database, yes. That should not be a problem.

What to save, and how? The first thing to do is to ignore that fact that this is an email. It isn't., not yet. What you need to save is the information the user is working on, in a format so that he can resume working on it later. This does not have much to do with email: it has to do with your form layout and content. So what you need to save is a field for each input on your form: subject and body probably as a minimum, plus whatever other info you need to recreate the form in the condition it was when he temporarily stopped working on it.

If you are using a database, it would need:
Row id        - because every row needs a unique ID
User id       - so you only retrieve his emails
Body text     - because he typed it
Subject text  - ditto
...           - because your form needs them


Make sense?
 
Share this answer
 
[Alternative suggestion to Griff's response]

You could consider serializing the MailMessage object. Here are two related links:

http://nayyeri.net/how-to-serialize-a-mailmessage[^]

http://meandaspnet.blogspot.com/2009/10/how-to-binary-serialize-mailmessage-for.html[^]
 
Share this answer
 

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