简体   繁体   English

Windows SendTo从脚本

[英]Windows SendTo from script

I'm writing an application where I have to send an email with an attachment using the default mail application. 我正在编写一个应用程序,必须使用默认的邮件应用程序发送带有附件的电子邮件。

Before the email is sent, I want the user to be able to edit the text, ie the application should just open the mail client with pre-filled recipient and attachment and give the user the opportunity to send it. 在发送电子邮件之前,我希望用户能够编辑文本,即应用程序应该只打开带有预先填写的收件人和附件的邮件客户端,并为用户提供发送邮件的机会。

At very minimum I need the same effect I'd got if I selected "SendTo/Mail Recipient" from the context menu of the file. 如果我从文件的上下文菜单中选择“发送/邮件收件人”,则至少需要获得与我相同的效果。

Solutions based on the "mailto:" trick won't work as there are mail clients that do not support the "attachment=" part. 基于“ mailto:”技巧的解决方案将不起作用,因为有些邮件客户端不支持“ attachment =”部分。

The most complete solution I've found is this one: http://www.codeproject.com/Articles/3839/SendTo-mail-recipient but it seems a lot of code for something so simple! 我发现的最完整的解决方案是以下解决方案: http : //www.codeproject.com/Articles/3839/SendTo-mail-recipient,但是对于这么简单的事情,似乎有很多代码! (and also crashes when compiled with VS2008) (并且在使用VS2008编译时也会崩溃)

Is there any other option? 还有其他选择吗? It would be ok even if it was an external tool or script (eg a .vbs script to be launched with cscript). 即使它是外部工具或脚本(例如,将与cscript一起启动的.vbs脚本)也可以。

I would advise you to use MAPI ( Messaging Application Program Interface ). 我建议您使用MAPI( 消息应用程序接口 )。

If dotNet can be part of the solution, here's a ready-to-use class in C# : Class for creating MAPI Mail Messages . 如果dotNet可以作为解决方案的一部分,那么这是C#中的一个现成可用的类: 用于创建MAPI邮件消息的类 It would give you something like this: 它会给你这样的东西:

MapiMailMessage message = new MapiMailMessage("Test Message", "Test Body");
message.Recipients.Add("Test@Test.com");
message.Files.Add(@"C:\del.txt");
message.ShowDialog();

Otherwise, you can always do it in C++ if you feel confortable with it, like this answer suggest. 否则,如果您对它感到不舒服,就可以始终使用C ++进行操作,如该答案所示。

Then, you will be able to ShellExecute the binary executable and pass it some parameters. 然后,您将能够ShellExecute二进制可执行文件并将其传递一些参数。

Hope this helps :-) 希望这可以帮助 :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM