Dim OutLooks As Outlook.Application
Private Sub Command1_Click()
Call send_mail("Then IA CODE is going to run out! ")
End Sub
Public Function OutLookMailto(OutLooks As Outlook.Application, _
ByVal strSubject As String, _
ByVal strText As String, colAddrList As Collection, _
colAttachments As Collection) As Boolean
Dim Mail As MailItem
Dim strTemp
Set OutLooks = New Outlook.Application
Set Mail = OutLooks.CreateItem(olMailItem) '設定要一個新的Mail Item
With Mail
For Each strTemp In colAddrList
.Recipients.Add strTemp '新增收件人
Next
' For Each strTemp In colAttachments
' .Attachments.Add strTemp 'Attach的File
' Next
.Subject = strSubject '主旨
.Body = strText '內容
.Save '存入寄件夾
.Display
' .Send '出信件
End With
Set Mail = Nothing
OutLookMailto = True
Exit Function
Errh:
OutLookMailto = False
End Function
Private Sub send_mail(ByVal strSubject As String)
Dim colAddrs As New Collection
Dim colAttachs As New Collection
Dim strBody As String
Dim strText As String
Dim blnSendOK As Boolean
Dim SQL As String
' SQL = "select email_address from sftm40 where email_group = 'ME ' "
' Set RS = DB.Execute(SQL)
' strBody = "您好: " & vbCrLf & " 您看到這封信時表示已成功傳送 "
'While Not RS.EOF
colAddrs.Add "huajun.zhou@arima.com.cn " ' "jianhong.wu@arima.com.cn " 'Trim(RS.Fields( "email_address "))
' RS.MoveNext
'Wend
'colAttachs.Add mFile
colAttachs.Add " "
strText = " The has already run out, please send the new range to Arima S/W team.& " _
& " Thank you very much! This mail for test program. "
blnSendOK = OutLookMailto(OutLooks, strSubject, strText, colAddrs, colAttachs)
If blnSendOK = True Then
MsgBox "彈出窗口成功! ", vbInformation
Else
MsgBox "彈出窗口未成功! ", vbInformation
End If
'End
End Sub
On Error Resume Next
outlookObj = GetObject(, "Outlook.Application")
If Err.Number = 0 Then
MsgBox("Outlook is running")
Else
MsgBox("Outlook is not running")
Set outlookObj = New Outlook.Application
End If
Err.Clear()
.........
outlookObj = Nothing
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。