Function send_mail()
Dim send2 As New ADODB.Recordset
Dim send3 As New ADODB.Recordset
Dim olkapp As Outlook.Application
Dim newmail As MailItem
Dim para As String
Dim i As Integer
Set olkapp = CreateObject("outlook.application")
send2.Open "select * from [7-28] order by 快件号码", CurrentProject.Connection, adOpenKeyset, adLockReadOnly
send3.Open "select * from [7-28子],[7-28] where [7-28子].快件ID=[7-28].快件ID", CurrentProject.Connection, adOpenKeyset,adLockReadOnly
If send2.RecordCount < 1 Then Exit Function
With send2
para = "dear super"
para = para + "<html><font size=5 face=Tahoma><b><center>EXPRESS<br></b><font face=Tahoma size=2>.O.D Reports</font>" & _
"<br><p align=right><font face=Tahoma size=2>rint Date:" & Date & "</p>"
For i = 1 To .RecordCount
para = para + "<head><tbody>" & _
"<br><tr><table border=0 cellpadding=1>" & _
"<th width=100 align=left><font face=Tahoma size=2><b>In-Date</b></th>" & _
"<th width=100 align=left><font face=Tahoma size=2><b>od No</b></th>" & _
"<tr><td width=100 align=left><font face=Tahoma size=2>" & CStr(.Fields("发件日")) & "</td>" & _
"<td width=100 align=left><font face=Tahoma size=2>" & CStr(.Fields("快件号码")) & "</td>" & _
"<tr><td width=100 align=left><font face=Tahoma size=2>" & CStr(send3.Fields("日期")) & "</td>" & _
"<td width=500 align=left><font face=Tahoma size=2>" & CStr(send3.Fields("递送经过")) & "</td>" & _
"</tbody></head>"
.Move i, 1
Next i
End With
send2.Close
Set newmail = olkapp.CreateItem(olMailItem)
With newmail
.To = "ggggggg5@hotmail.com"
.Subject = Format(Date, "mmm dd")
.BodyFormat = olFormatHTML
.HTMLBody = para
.send
End With
End Function