C
CJ
Hi Groupies
I am working with code to send emails to multiple recipients
If I push the button to send the email and then if I cancel out of Outlook
and return to Access, my database freezes if I push the button to send the
email again.
This problem happens with either Access 2003 or 2007. I have Outlook 2007
and a Vista machine.
My complete code is as follows:
Option Compare Database
Option Explicit
Private Sub cmdSendEmail_Click()
On Error GoTo Err_cmdSendEmail_Click
' ©Arvin Meyer 1999-2004
' Permission to use is granted if copyright notice is left intact.
' Permisssion is denied for use with unsolicited commercial email
Dim strContacts As String
Dim strSubject As String
Dim strMessage As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
strContacts = Me.txtSelected & vbNullString
strSubject = Me.txtSubject & vbNullString
strMessage = Me.txtMessage & vbNullString
DoCmd.SendObject acSendNoObject, , acFormatHTML, To:=strContacts,
Subject:=strSubject, MessageText:=strMessage
Exit_cmdSendEmail_Click:
Set rst = Nothing
Set db = Nothing
Exit Sub
Err_cmdSendEmail_Click:
MsgBox Err.Description
Resume Exit_cmdSendEmail_Click
End Sub
Private Sub lstContacts_Click()
Dim varItem As Variant
Dim strList As String
With Me!lstContacts
If .MultiSelect = 0 Then
Me!txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & ";"
Next varItem
strList = Left$(strList, Len(strList) - 1)
Me!txtSelected = strList
End If
End With
End Sub
Thanks for having a look at this for me.
I am working with code to send emails to multiple recipients
If I push the button to send the email and then if I cancel out of Outlook
and return to Access, my database freezes if I push the button to send the
email again.
This problem happens with either Access 2003 or 2007. I have Outlook 2007
and a Vista machine.
My complete code is as follows:
Option Compare Database
Option Explicit
Private Sub cmdSendEmail_Click()
On Error GoTo Err_cmdSendEmail_Click
' ©Arvin Meyer 1999-2004
' Permission to use is granted if copyright notice is left intact.
' Permisssion is denied for use with unsolicited commercial email
Dim strContacts As String
Dim strSubject As String
Dim strMessage As String
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb
strContacts = Me.txtSelected & vbNullString
strSubject = Me.txtSubject & vbNullString
strMessage = Me.txtMessage & vbNullString
DoCmd.SendObject acSendNoObject, , acFormatHTML, To:=strContacts,
Subject:=strSubject, MessageText:=strMessage
Exit_cmdSendEmail_Click:
Set rst = Nothing
Set db = Nothing
Exit Sub
Err_cmdSendEmail_Click:
MsgBox Err.Description
Resume Exit_cmdSendEmail_Click
End Sub
Private Sub lstContacts_Click()
Dim varItem As Variant
Dim strList As String
With Me!lstContacts
If .MultiSelect = 0 Then
Me!txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strList & .Column(0, varItem) & ";"
Next varItem
strList = Left$(strList, Len(strList) - 1)
Me!txtSelected = strList
End If
End With
End Sub
Thanks for having a look at this for me.