gpt4 book ai didi

c# - 如何在 c# 中不使用 httppostedfilebase 发送电子邮件附件?

转载 作者:太空宇宙 更新时间:2023-11-03 12:55:40 24 4
gpt4 key购买 nike

我使用 angularjs 通过 ajax 提交表单以调用我的 mvc Controller 中的操作。和使用我的 Angular 指令,我可以获得所选文件的文件名、内容类型和内容长度。我从 Angular 提取的这三个信息是否足以将文件附加到我的电子邮件中?谢谢大家的帮助。

最佳答案

I can get the filename, contenttype and contentlength of the selected file.

不,这还不足以将文件作为邮件附件发送。没有文件的内容,上述所有详细信息都没有值(value)。

编辑:如果您计划在您的 mvc Controller 中发布 HttpPostedFileBase,那么您可以提取上述详细信息,如下所示。

获取扩展:

string extension = Path.GetExtension(upload.FileName);

其中上传的类型为 HttpPostedFileBase。

获取文件名:

string fileName = Path.GetFileName(upload.FileName);

获取文件类型:

string contentType = upload.ContentType

关于c# - 如何在 c# 中不使用 httppostedfilebase 发送电子邮件附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34017192/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com