email from Access - no Outlook (1 Viewer)

paulreed

Registered User.
Local time
Today, 06:42
Joined
Jan 30, 2003
Messages
42
There are many previous messages relating to generating email messages from Access by using Outlook, but is there a more basic way in which emails can be generated where Outlook is not installed (like the corporate system where I work!!).
I have written a db which identifies staff members who have forgotten to submit paperwork, and I presently print them a report, and send it by snailmail, but want to be able to email them as a batch instead.
Outlook is not installed on the intranet, but Lotus Domino is used instead (not the full client - just the web based version). Is there a way I can generate emails using the SMTP server directly from code?

I have found the following code, but cannot get it to work, does it make sense to you?

Sub STMPSend(strMyDomain As String, _
strEmailServer As String, _
strEmailAddressWithoutDomain As String, _
strWhoToSayThisIsFrom As String, _
strSubject As String, _
strMessageBody As String)
WinSock1.RemoteHost = strEmailServer
WinSock1.RemotePort = 25
WinSock1.Connect

WaitForIt
Select Case Left$(strWSIn, 3)
Case "220"
' connected ok, send HELLO
WinSock1.SendData "HELO " & _
strMyDomain & _
vbCrLf
WaitForIt
WinSock1.SendData "MAIL FROM: " & _
strWhoToSayThisIsFrom & _
vbCrLf
WaitForIt
WinSock1.SendData "RCPT TO: " & _
strWhoToSayThisIsFrom & _
vbCrLf
WaitForIt
WinSock1.SendData "DATA" & vbCrLf & _
"DATE:" & _
Format$(Now(), "mm/dd/yyyy hh:mm:ss") & _
"FROM: " & _
strWhoToSayThisIsFrom & vbCrLf & _
"TO:" & _
Format$(Now(), "mm/dd/yyyy hh:mm:ss") & _
"DATE:" & _
Format$(Now(), "mm/dd/yyyy hh:mm:ss") & _
"SUBJECT: " & _
strSubject & _
vbCrLf & _
strMessageBody & _
vbCrLf & _
"." & vbCrLf
' note: . & vbcrlf terminates the "send"
WaitForIt
' parse and validate the return from the sever
End Select
' tell the server you're done:
WinSock1.SendData "QUIT" & vbCrLf
' and that's it!
WinSock1.Close
End Sub

Private Sub WaitForIt()
WaitingForData = True
While WaitingForData = True
DoEvents
Wend
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim Temp As String
Temp = String(bytesTotal, " ")
WinSock1.GetData Temp, vbString
Do
If Right$(Temp, 1) = vbLf Then
Temp = Left$(Temp, Len(Temp) - 1)
End If
Loop While Right$(Temp, 1) = vbLf
strWSIn = Temp
WaitingForData = False
End Sub
 
Last edited:

paulreed

Registered User.
Local time
Today, 06:42
Joined
Jan 30, 2003
Messages
42
Not sure if the last post helps or not?

Could you advise me how to use the code above, I'm not sure how to run it, or if it will fulfill my expectations. I'm still learning Access and would appreciate any support.

Thanks
 

Kodo

"The Shoe"
Local time
Today, 01:42
Joined
Jan 20, 2004
Messages
707
in order for this to work, you must have IIS installed with STMP services


PHP:
Dim mymail As Object
   
   Set mymail = CreateObject("CDONTS.NewMail")
    mymail.From = "Kodo"
    mymail.To = "me@where.com"
    mymail.Subject = "Hello"
    mymail.BodyFormat = 0
    mymail.MailFormat = 0
    mymail.Body = "This is the body"
On Error Resume Next
   mymail.Send
    Set mymail = Nothing



   If Err <> 0 Then
      Response.Write "Error encountered: " & Err.Description


  Else
MsgBox "Thank You! Your Mail Has Been Sent", vbOKOnly, "Mail Sent"


   End If
 

keiths

Registered User.
Local time
Yesterday, 23:42
Joined
Feb 10, 2005
Messages
28
Sending email without using outlook, etc

I found a very handy dll that allows you to send email from within your ms access database (also ms excel). This allows you to send email without the use of ms outlook or other email clients.
The web site for the dll is:

http://www.ostrosoft.com/smtp_component.asp

The zip download includes a number of samples for different programming languages. What I liked about this smtp email dll is that I can set up a "monitor window" where I can see what is happening with the smtp server so I can see errors, etc.
The coding is fairly straight forward, and is easy to implement.

They also have a dll for reading emails. Have played with it a bit, and it also seems to work fine.
 

Users who are viewing this thread

Top Bottom