在api中,用shellexecute可以调出邮件程序,如outlook express,但是能否同时把附件添加上呢? 命令又是怎么写的? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这有一个VB的例子:先声明API函数ShellExecute:Private Declare Function ShellExecute Lib "shell32.dll" _ Alias "ShellExecuteA" (ByVal hWnd As Long, _ ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory _ As String, ByVal nShowCmd As Long) As LongPrivate Const SW_SHOWNORMAL = 1再看一下MailTo的语法:MailTo:Address[&CC=抄送人列表][&BCC=暗送人列表][&Subject=标题][&Body=邮件正文][&Attach=用引号包含的附件文件名]好了,就这么简单,你的VB程序只要生成这样一个字符串传给ShellExecute就行了。创建一个新VB工程,窗体上加入6个 textbox和一个按钮(cmdSendIt),把上面的声明和下面的代码Paste过去:Private Sub cmdSendIt_Click()Dim sText As StringDim sAddedText As StringIf Len(txtMainAddresses) Then sText = txtMainAddressesEnd IfIf Len(txtCC) Then sAddedText = sAddedText & "&CC=" & txtCCEnd IfIf Len(txtBCC) Then sAddedText = sAddedText & "&BCC=" & txtBCCEnd IfIf Len(txtSubject) Then sAddedText = sAddedText & "&Subject=" & txtSubjectEnd IfIf Len(txtBody) Then sAddedText = sAddedText & "&Body=" & txtBodyEnd IfIf Len(txtAttachmentFileLocation) Then sAddedText = sAddedText & "&Attach=" & _ Chr(34) & txtAttachmentFileLocation & Chr(34)End IfsText = "mailto:" & sText' clean the added elementsIf Len(sAddedText) <> 0 Then' there are added elements, replace the first' ampersand with the question character Mid$(sAddedText, 1, 1) = "?"End IfsText = sText & sAddedTextIf Len(sText) Then Call ShellExecute(Me.hWnd, "open", sText, _ vbNullString, vbNullString, SW_SHOWNORMAL)End IfEnd Sub说明:有的邮件程序可能不支持所有的参数。 to wpg():请教一个问题:"邮件正文"里面可以回车换行吗?怎么表示?谢谢! 为什么在Delphi中,attach参数用不了啊? office 自己带的 outlook 可以实现,但是如果用系统IE 的Outlook 5.0 hu或 OutLook 6.0 好像不行,我以前也做过类似的东西。 哈哈,问到我了,不过分要给我 :-)第一:OutLook支持添加附件,OutLook Express不支持第二:你试试 '我要换&0d&0a行'; 在Delphi怎么用字符类型的数据来查询access中的时间类型的字段? 谁能帮我解释一下每一句的意思? 祝大家元旦快乐,身体健康,事事如意! 如何实现多线程 移动记录问题 请问在delphi开发当中如何进行多人协作。 基础问题2 有济南的吗?合伙做项目? DELPHI怎样写Webserverice接口开发? 在DELPHI中使用ACCESS数据库是不是一定要装ACCESS呀?? 小的不才。关于 三层结构和c/s结构 locate 问题
先声明API函数ShellExecute:
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory _
As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1再看一下MailTo的语法:MailTo:Address[&CC=抄送人列表][&BCC=暗送人列表][&Subject=标题][&Body=邮件正文][&Attach=用引号包含的附件文件名]好了,就这么简单,你的VB程序只要生成这样一个字符串传给ShellExecute就行了。创建一个新VB工程,窗体上加入6个 textbox和一个按钮(cmdSendIt),把上面的声明和下面的代码Paste过去:Private Sub cmdSendIt_Click()Dim sText As StringDim sAddedText As StringIf Len(txtMainAddresses) Then sText = txtMainAddressesEnd IfIf Len(txtCC) Then sAddedText = sAddedText & "&CC=" & txtCCEnd IfIf Len(txtBCC) Then sAddedText = sAddedText & "&BCC=" & txtBCCEnd IfIf Len(txtSubject) Then sAddedText = sAddedText & "&Subject=" & txtSubjectEnd IfIf Len(txtBody) Then sAddedText = sAddedText & "&Body=" & txtBodyEnd IfIf Len(txtAttachmentFileLocation) Then sAddedText = sAddedText & "&Attach=" & _ Chr(34) & txtAttachmentFileLocation & Chr(34)End IfsText = "mailto:" & sText' clean the added elementsIf Len(sAddedText) <> 0 Then' there are added elements, replace the first' ampersand with the question character Mid$(sAddedText, 1, 1) = "?"End IfsText = sText & sAddedTextIf Len(sText) Then Call ShellExecute(Me.hWnd, "open", sText, _
vbNullString, vbNullString, SW_SHOWNORMAL)End IfEnd Sub说明:有的邮件程序可能不支持所有的参数。