igg,
I am not a developer and am no way as capable as any of the experts that will
answer you, but I use Blat.exe to send reports using SMTP. You can download
the exe from
www.blat.net and place blat.exe in the same folder as your
application. I use it to email reports that have been converted to pdf.
The following websites are what I used and you may get some ideas from them.
http://www.blat.net/
http://www.blat.net/newdocs/MSAccess_class.html
http://www.freevbcode.com/ShowCode.Asp?ID=109
http://www.rogersaccesslibrary.com/forum/forum_posts.asp?TID=149
There sia lso a blat usergroup on Yahoo groups.
Tony Teows also has a page at:
http://www.granite.ab.ca/access/email.htm
Code that I have used is listed below. I use a function written by Francisco
H Tapia and it is in the sample database downloaded from Rogers Access
Library listed above ( if I remember correctly).
The function below is called like this:
SendBlatMail strFromEmail, strFromMail, strToMail, strSubject, strMessage,
strMessageAttachment
Function SendBlatMail(strFromName As String, strFrom As String, strRecipient
As Variant, strSubject As String, strBody As String, Optional
strSavedFileName As Variant)
'-----------------------------------------------------------------------------
----------
' Procedure : SendBlatMail
' DateTime : 2002-12-27 08:27am
' Author : Francisco H Tapia
' Variables : strFromName (email Name), strFrom (email address), strRecipient
(list of address separated by a comma ",")
' strSubject (string), strBody (string), strAttachment (full path
to attachments separated by a comma ",")
' Purpose : Replacement send email function, this function makes a full
call to the BLAT utility.
'-----------------------------------------------------------------------------
----------
'
Dim strRecipientList As String
Dim strAttachmentList As String
Dim strMail As String
Dim i As Integer
Dim strOrganisation As String
Dim strResponse As String
Dim strHost As String
On Error GoTo SendBlatMail_Error
strOrganisation = "Organisation Name"
strHost = "Host name"
If IsArray(strRecipient) Then
For i = LBound(strRecipient) To UBound(strRecipient)
If Len(strRecipientList) = 0 Then
strRecipientList = "-t " & Chr(34) & strRecipient(i)
Else
strRecipientList = strRecipientList & " , " & strRecipient(i)
End If
Next
strRecipientList = strRecipientList & Chr(34)
Else
strRecipientList = "-t " & Chr(34) & strRecipient & Chr(34)
End If
If Not IsMissing(strSavedFileName) And Not IsEmpty(strSavedFileName) Then
If IsArray(strSavedFileName) Then
For i = LBound(strSavedFileName) To UBound(strSavedFileName)
strAttachmentList = " -attach " & Chr(34) & strSavedFileName
(i)
Next
strAttachmentList = strAttachmentList & Chr(34)
Else
strAttachmentList = " -attach " & Chr(34) & strSavedFileName &
Chr(34)
End If
End If
strMail = " " & strAttachmentList
If strMail <> "" Then
strMail = strMail & " -subject " & Chr(34) & strSubject & Chr(34)
Else
strMail = " -subject " & Chr(34) & strSubject & Chr(34)
End If
strMail = strMail & " " & strRecipientList
strMail = strMail & " -f " & Chr(34) & strFrom & Chr(34)
strMail = strMail & " -from " & Chr(34) & strFromName & Chr(34)
strMail = strMail & " -org " & Chr(34) & strOrganisation & Chr(34)
strMail = strMail & " -HostName " & Chr(34) & strHost & Chr(34)
strMail = strMail & " -x " & Chr(34) & "X-INFO: BLAT Message" & Chr(34)
strMail = strMail & " -noh"
strMail = strMail & " -noh2"
strMail = strMail & " -log " & Chr(34) & ShortPath(CurrentProject.path &
"\BlatLOG.txt") & Chr(34)
'ADD YOUR SMTP SERVER IP AND USER ID AND PASSWORD HERE SO THAT THE
MAIL ACTUALLY SENDS.
strMail = strMail & " -server " & Chr(34) & "SMTP SERVER IP" & Chr(34)
strMail = strMail & " -port 25"
strMail = strMail & " -u " & Chr(34) & "SMTP Username" & Chr(34)
strMail = strMail & " -pw " & Chr(34) & "SMTP Password" & Chr(34)
strMail = strMail & " -try 3"
'strMail = strMail & " -debug"
strMail = strMail & " -timestamp"
'Location of BLAT.
Call ShellWait(CurrentProject.path & "\blat.exe" & " - " & strMail & " -
body " & Chr(34) & strBody & Chr(34), vbHide)
i = FreeFile
Open ShortPath(CurrentProject.path & "\BlatLOG.txt") For Input As i
While Not EOF(i)
Input #i, strResponse
If InStr(1, strResponse, "The mail server", vbTextCompare) = 1 Or _
InStr(1, strResponse, "Have you", vbTextCompare) = 1 Then
MsgBox strResponse, vbOKOnly + vbExclamation, "Email Failed!"
End If
Wend
Close #i
Kill ShortPath(CurrentProject.path & "\BLATLOG.txt")
SendBlatMail_Exit:
On Error Resume Next
On Error GoTo 0
DoCmd.Hourglass False
Exit Function
SendBlatMail_Error:
If Err.Number = 2501 Then
Resume Next
Else
Select Case Err
Case Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in
procedure SendBlatMail of Module modBlat", vbExclamation + vbOKOnly, "Help."
End Select
End If
Resume SendBlatMail_Exit
Resume
End Function
*********************************
Hope that helps you.
Anthony