我的构思是:从SQL把数据导出到RS上面。然后直接发邮件出去,把RS的内容直接在邮件正文显示。 这里有同学知道怎么做吗? 单独的从SQL 导数据到EXCEL,我会。从EXCEL发附件我也会。 但是我就是不知道怎么把内容直接在邮件正文显示,我不想用附件形式。 请大虾帮我。下面是构思. 1.---从sql 导出数据到rs集合中 Sub test_mail() Dim i As Integer, j As Integer, sht As Worksheet Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim strCn As String, strSQL As String strCn = "Provider=sqloledb;Server=westgua;Database=test;Uid=test;Pwd=test^^" strSQL = "select * from test.dbo.bb" cn.Open strCn rs.Open strSQL, cn ???这里就是需要大虾帮我的了.如何让RS的内容给BODY Call SendMail(Adress, Subject, Body, Attachment) End Sub
2.---发邮件 Sub SendMail Dim objOL As Object Dim itmNewMail As Object Dim olMailItem Set objOL = CreateObject("Outlook.Application") Set itmNewMail = objOL.CreateItem(olMailItem) With itmNewMail .Subject = Subject .Body = ?? '这里希望是rs的内容 .To = 1111@163.com
End With On Error GoTo continue SendEmail: itmNewMail.display DoEvents DoEvents DoEvents SendKeys "%s", Wait:=True DoEvents itmNewMail.display GoTo SendEmail continue: On Error GoTo 0 Set objOL = Nothing Set itmNewMail = Nothing
rs.Close End Sub
[此贴子已经被作者于2006-8-29 16:06:43编辑过] |