保存为草稿,在asp.net中发送电子邮件功能 [英] Save to Draft, Sent email functionality in asp.net

查看:91
本文介绍了保存为草稿,在asp.net中发送电子邮件功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个代码,用于在asp.ent中发送邮件.只是为了让两个用户可以交流

Hi all,

i have a code written for Send mail in asp.ent. This is just so that two users can communicate

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";   
       }

    }
}


这是我用于发送功能的代码

现在,我应该如何执行保存到草稿".我应该将其保存到数据库中吗?
保存到草稿中需要考虑哪些事项

我是初学者,请原谅我的幼稚问题

谢谢
smitha


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

推荐答案

保存到草稿"可以保存到数据库,是的.那应该没问题.

保存什么以及如何保存?首先要做的就是忽略这是一封电子邮件的事实.还不是.您需要保存的是用户正在使用的信息,其格式应为用户以后可以继续使用.这与电子邮件无关,它与您的表单布局和内容有关.因此,您需要保存的是表单上每个输入的字段:主题和正文可能至少是一个字段,再加上在他暂时停止处理表单时要重新创建表单所需的其他信息. >
如果您使用的是数据库,则需要:
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?


[对格里夫回应的替代建议]

您可以考虑序列化MailMessage 对象.这是两个相关的链接:

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

http://meandaspnet.blogspot.com/2009/10/how- to-binary-serialize-mailmessage-for.html [ ^ ]
[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[^]


这篇关于保存为草稿,在asp.net中发送电子邮件功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆