我想检索邮件附件并将其存储,bytes[]以便我可以将它们插入到列附件varbinary类型的表中.在Windows窗体中我正在使用OpenFileDialog,我不知道如何在一个byte[]类型中获取文件的字节,以便我可以将其插入到SQLServer中的表中.
这是代码:
namespace fyp8
{
public partial class ComposeMail : Form1
{
ArrayList alAttachments;
MailMessage mmsg;
string conn = @"Data source=(local);Initial Catalog=fyp;Integrated Security=true";
public ComposeMail()
{
InitializeComponent();
}
private void ComposeMail_Load(object sender, EventArgs e)
{
}
private void btnAttachment_Click(object sender, EventArgs e)
{
OpenFileDialog odflg = new OpenFileDialog();
odflg.ShowDialog();
if (odflg.ShowDialog() == DialogResult.OK)
{
try
{
txtAttachments.Text = odflg.FileName;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error");
}
}
}
private void btnSend_Click(object sender, …Run Code Online (Sandbox Code Playgroud)