not another notification by email problem

Markvand

Registered User.
Local time
Today, 19:42
Joined
Jul 13, 2004
Messages
88
hi all,

I know it has been here few times already, but all the bids and pieces I found were not particulary usufull in my case.

What I want to do, is after user fills all the fields in the form, he/she has a message "do you want to save it" Y/N,

After clicking on yes, obviously the form is saved and email is sent to group of user (the best thing would be to have it done in background without user awarness - the problem with Outlook security settings)

The other issue, I have a table with employee details grouped by departments, in this particular case I want to send it only to the particular group.

I know it should be done with SendObject but don't know exactly why, thus any help would be great.

Cheers

Mark
 
I came up with something like that:

Dim StrSearch As String
Dim rsEmail As DAO.Recordset
Dim strEmail As String
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML

Set rsEmail = CurrentDb.OpenRecordset("INQ_EMail")

' Send by connecting to port 25 of the SMTP server.

Const cdoSendUsingPort = 2

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

' Set the CDOSYS configuration fields to use port 25 on the SMTP server.

With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
'ToDo: Enter name or IP address of remote SMTP server.
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "intranet"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With

' Build HTML for message body.
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> </b></br>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("Email").Value

' Apply the settings to the message.
With iMsg
Set .Configuration = iConf
.To = strEmail 'ToDo: Enter a valid email address.
.From = StrSearch 'ToDo: Enter a valid email address.
.Subject = "Test"
.HTMLBody = "Test"
.Send
End With

' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

rsEmail.MoveNext

Loop
Set rsEmail = Nothing

MsgBox "Emails have been sent"


End Sub


I get the following error: Runtime error "91", Object Variable or With block variable not set, CDO Library is referenced


Any ideas?

Cheers

Mark
 

Users who are viewing this thread

Back
Top Bottom