如何打开带有附件的默认电子邮件客户端 [英] How to open default email client with attachment

查看:197
本文介绍了如何打开带有附件的默认电子邮件客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理我的项目的一个问题,当我单击按钮时,应该弹出一个默认的电子邮件客户端,如果有附件,应该像这样自动将其附加到默认的电子邮件客户端.

I'm working on an issue to my project that when I click the button, a default email client should pop out and if there's an attachment, it should be automatically attach to the default email client like this.

我已经尝试了很多方法来做到这一点.首先,我使用了MAPI,但是即使我已经在控制面板"中进行了设置,MAPI也无法检测到我的默认电子邮件客户端,它会显示这两个消息框

I already tried a lot of methods how to do this. First I used MAPI, but the MAPI cannot detect my Default Email Client even though I already set it in Control Panel, It shows this two message box

我已经在互联网上搜索了这些错误,但是没有明确或明确的答案. 这里是我在MAPI中使用的代码.

I already searched the internet about those error but there's no definite or clear answer to me. HERE'S the code I used in MAPI.

我还使用mail:to协议来调用使用此代码行处理上述协议的默认电子邮件客户端.

I used also the mail:to protocol to call the default email client who's handling to the aforementioned protocol with using this line of codes.

Dim proc As System.Diagnostics.Process = New System.Diagnostics.Process()

            Dim filename = Convert.toChar(34) & "C:\USERS\JOSHUA~1.HER\DOWNLO~1\ASDPOR~1.PDF" & Convert.toChar(34)
            Debug.Writeline(filename)
            Dim asd As String = String.Format("mailto:someone@somewhere.com?subject=hello&body=love my body&Attach={0}", filename)
            proc.StartInfo.FileName = asd
            proc.Start()

但是,仍然没有运气.我读了一个mail:to不再处理附件的线程,但是这一行代码打开了带有正文和主题的默认电子邮件客户端,但是没有附件.关于filename变量,我已经尝试了每种路径格式,我读到我应该使用8.3路径格式.但是仍然不起作用.

But still, no luck. I read a thread that the mail:to don't handle attachment anymore, but this line of code opened my default email client with body and subject, but there's no attachment. In terms of the filename variable, I already tried every path format, I read that I should use 8.3 path format. But still doesn't work.

我使用的最后一种方法是在答案之后扩展System.Net.MailMessage.MailMessage().这在打开默认电子邮件客户端并将附件附加到邮件方面起作用,但这是不可编辑的,并且默认电子邮件客户端上没有发送按钮,因为此行代码只是生成一个.eml文件并打开它.我正在考虑解析eml文件,但我仍然不知道如何以新的消息形式通过编程方式打开默认电子邮件客户端.这是照片

The last method I used is extending the System.Net.MailMessage.MailMessage() following THIS answer. This works in terms of opening the default email client and attaching an attachment to a mail, but this is not editable and there's no send button on the default email client because this line of code just generating an .eml file and opening it. I'm thinking of parsing the eml file but still I don't know how to open the default email client progmatically in a new message form. Here's the photo

你们知道如何实现这一目标吗?谢谢!

You guys have any idea how to make this possible? Thanks!

推荐答案

恐怕对于任何邮件客户端,使用某种通用方法都无法做到这一点.但是,您可以使用System.Net.Mail.SmtpClient和一些简单的自定义UI轻松创建自己的解决方案.

I am afraid that this will not be possible to do using some generic method for any mail client. But you can easily create your own solution using System.Net.Mail.SmtpClient and some simple custom UI.

这篇关于如何打开带有附件的默认电子邮件客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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