本文介绍了无法在C#中的电子邮件附件中附加多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我需要附加多个文件来发送邮件,并且按

In my project i need to attach multiple files to send mail and i am doing it as

        if (fDialog.ShowDialog() == DialogResult.OK)
        {
            textBox6.Text += fDialog.FileName.ToString() + ";";
        }

此处我将文件附加到文本框6

Here i am attaching the file in textbox6

我使用;分隔不同附件文件的路径。然后我按如下所示分离附件的那些路径,然后将其发送。

I am separating the paths of the different attachment file using ";" and then i separate those paths of the attachment as follows and then send it.

         System.Net.Mail.Attachment attachment;
        foreach (string m in textBox6.Text.Split(';'))
        {
            attachment = new System.Net.Mail.Attachment(m);
            message.Attachments.Add(attachment);
        }

此方法对我不起作用。但是当我发送带有以下代码的单个附件的邮件时,它就可以正常工作

This method don't work for me. But when i send mail with single attachment with the following code it just work fine

        System.Net.Mail.Attachment attachment;
        attachment = new System.Net.Mail.Attachment(textBox6.Text.ToString());
        message.Attachments.Add(attachment);

请帮助。我整整一天都在工作,无法解决。

Someone please help. I have been working this whole day and could not figure it out.

推荐答案

我希望这将完全解决您的问题

I hope this will solve your problem completely http://archive.msdn.microsoft.com/CSharpGmail

这篇关于无法在C#中的电子邮件附件中附加多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 05:47