nicklewisj
IS-IT--Management
Hi all, bit of a prob sending an e-mail to clients. the problem being with the below code is that it will send the message after all feilds are filled in outlook but then decides to start a new message as well any idea how to stop this so when the message is sent it goes back to access or is it better to write the whole e-mail in access via a new form and then it just sends the e-mail created, if this is a better way please provide any examples you may have on the best way to do this, thanks in advance to anyone who is kind enough to help and ill recommed
heres the code currently being used:
Private Sub cmdemail_Click()
On Error GoTo Err_Command0_Click
Dim stTo As String
Dim stCC As String
Dim stBCC As String
Dim stSubject As String
Dim stMessage As String
Dim sttest As String
Dim msg1 As String
sttest = ""
stTo = txtemail
stCC = ""
stBCC = ""
stSubject = ""
stMessage = ""
DoCmd.SendObject , , , stTo, stCC, stBCC, stSubject, stMessage
'Dim appOutLook As Outlook.Application, itm As Object, x As Integer
Set appOutLook = CreateObject("Outlook.Application")
Set itm = appOutLook.CreateItem(olMailItem)
With itm
.to = sEmail
.cc = Nz(txtcc, "")
.BCC = Nz(txtbcc, "")
.Subject = Nz(txtSubject, "")
.Body = Nz(txtMessage, "")
.Display (False)
.Send
End With
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
msg1 = MsgBox("Action cancelled, If this is causing a problem please contact your system administrator", vbOKOnly, "Action Cancelled")
Resume Exit_Command0_Click
End Sub