在api中,用shellexecute可以调出邮件程序,如outlook express,但是能否同时把附件添加上呢?

northwind001 2002-12-06 10:34:21
命令又是怎么写的?
...全文
75 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwind001 2002-12-09
  • 打赏
  • 举报
回复
为什么在Delphi中,attach参数用不了啊?
crossbow 2002-12-09
  • 打赏
  • 举报
回复
哈哈,问到我了,不过分要给我 :-)

第一:OutLook支持添加附件,OutLook Express不支持

第二:你试试 '我要换&0d&0a行';
smandhgx 2002-12-09
  • 打赏
  • 举报
回复
office 自己带的 outlook 可以实现,但是如果用系统IE 的Outlook 5.0 hu或 OutLook 6.0 好像不行,我以前也做过类似的东西。
northwind001 2002-12-07
  • 打赏
  • 举报
回复
谢谢wpg
invalid 2002-12-06
  • 打赏
  • 举报
回复
我很少流窜,你看我的两个三角就知道了。
myy 2002-12-06
  • 打赏
  • 举报
回复
to wpg():

请教一个问题:"邮件正文"里面可以回车换行吗?怎么表示?谢谢!
wpg 2002-12-06
  • 打赏
  • 举报
回复
这有一个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 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 String

Dim sAddedText As String

If Len(txtMainAddresses) Then

sText = txtMainAddresses

End If

If Len(txtCC) Then

sAddedText = sAddedText & "&CC=" & txtCC

End If

If Len(txtBCC) Then

sAddedText = sAddedText & "&BCC=" & txtBCC

End If

If Len(txtSubject) Then

sAddedText = sAddedText & "&Subject=" & txtSubject

End If

If Len(txtBody) Then

sAddedText = sAddedText & "&Body=" & txtBody

End If

If Len(txtAttachmentFileLocation) Then

sAddedText = sAddedText & "&Attach=" & _

Chr(34) & txtAttachmentFileLocation & Chr(34)

End If

sText = "mailto:" & sText

' clean the added elements

If Len(sAddedText) <> 0 Then

' there are added elements, replace the first

' ampersand with the question character

Mid$(sAddedText, 1, 1) = "?"

End If

sText = sText & sAddedText

If Len(sText) Then

Call ShellExecute(Me.hWnd, "open", sText, _
vbNullString, vbNullString, SW_SHOWNORMAL)

End If

End Sub

说明:有的邮件程序可能不支持所有的参数。
myy 2002-12-06
  • 打赏
  • 举报
回复
to 空心菜: 与你一样,四处“流窜”。
myy 2002-12-06
  • 打赏
  • 举报
回复
看到有人介绍过,因为不用,忘了。可以到网上搜搜。
invalid 2002-12-06
  • 打赏
  • 举报
回复
不行的。

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧