M
Marcus
Below my coding to send mails to all adresses.
But I have a problem to automate completely.
I always have to confirm the mail before it will be send; a response to
Allow / Deny / Help must be given on a Microsoft Office Outlook message
window.
I've played arround with trusted settings for the database without success.
error message:
A proram is trying to send an e-mail message on your behalf. If this is
unexpected, click deny and verify your antivirus software is up-to-date. For
more information about e-mail safty and how you might be able to avoid
getting this warning, click help.
The concerned module:
Private Sub cmdTO_Click()
On Error GoTo ErrorMsgs
Dim MyTO As Variant, MyCC As Variant, MyBC As Variant, MyField As Variant
Dim MyRecordsetClone As Recordset
Dim MySubject As String, MyBody As String
' provide a default subject in case the form does not have a subject field
MySubject = "Subject : "
If Me.Parent.MailSubject > " " Then MySubject = Me.Parent.MailSubject
' provide a default body content in case the form does not have a subject
field
MyBody = "Body : "
If Me.Parent.MailBody > " " Then MyBody = Me.Parent.MailBody
' clone theform recordset to have access to all records remaining after
applying different filtering instructions
Set MyRecordsetClone = Me.RecordsetClone
MyTO = ""
MyRecordsetClone.MoveFirst
Do While Not MyRecordsetClone.EOF
' each mail operation will have a TO-Address field less than 20470
characters
Do While Not (MyRecordsetClone.EOF) And Not (Len(MyTO) > 20470)
MyField = " "
Do While Len(MyField) > 0
' find all e-mail references with the "enabled" constraint
(available as text. e.g. "(e-mail address removed);enabled")
MyField = DLookup("Entitys_Peculiaritys.Content",
"Entitys_Peculiaritys", " ((Entitys_Peculiaritys.EntityHint = " &
MyRecordsetClone("EntityKey") & ") AND (Entitys_Peculiaritys.PeculiarityHint
= 5) and (Entitys_Peculiaritys.Content like ""*enabled*"") and ( instr(1,"""
& MyTO & """ , Entitys_Peculiaritys.Content ) = 0 ) )")
If MyField > " " Then
MyTO = Replace(Trim(MyTO), ";;", ";") & ";" & MyField & vbCrLf
End If
Loop
MyRecordsetClone.MoveNext
Loop
' remove constraint as text information
MyTO = Replace(Replace(MyTO, " ", ""), ";enabled", "")
If MyTO > " " Then
'send message to the inluded addressees
DoCmd.SendObject acSendNoObject, , , Mid(MyTO, 2, Len(MyTO) - 1), ,
, MySubject, MyBody, True
MsgBox "Over to next blok of mails"
End If
MyRecordsetClone.MoveNext
Loop
Exit Sub
ErrorMsgs:
Select Case Err.Number
Case 2501, 3021
Case 287
MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail" & _
"addresses to send your message. For more information, " & _
"see the document at
http://www.microsoft.com/office/previous/outlook/downloads/security.asp. "
Case Else
MsgBox CStr(Err.Number) & " - " & Err.Description
End Select
End Sub
But I have a problem to automate completely.
I always have to confirm the mail before it will be send; a response to
Allow / Deny / Help must be given on a Microsoft Office Outlook message
window.
I've played arround with trusted settings for the database without success.
error message:
A proram is trying to send an e-mail message on your behalf. If this is
unexpected, click deny and verify your antivirus software is up-to-date. For
more information about e-mail safty and how you might be able to avoid
getting this warning, click help.
The concerned module:
Private Sub cmdTO_Click()
On Error GoTo ErrorMsgs
Dim MyTO As Variant, MyCC As Variant, MyBC As Variant, MyField As Variant
Dim MyRecordsetClone As Recordset
Dim MySubject As String, MyBody As String
' provide a default subject in case the form does not have a subject field
MySubject = "Subject : "
If Me.Parent.MailSubject > " " Then MySubject = Me.Parent.MailSubject
' provide a default body content in case the form does not have a subject
field
MyBody = "Body : "
If Me.Parent.MailBody > " " Then MyBody = Me.Parent.MailBody
' clone theform recordset to have access to all records remaining after
applying different filtering instructions
Set MyRecordsetClone = Me.RecordsetClone
MyTO = ""
MyRecordsetClone.MoveFirst
Do While Not MyRecordsetClone.EOF
' each mail operation will have a TO-Address field less than 20470
characters
Do While Not (MyRecordsetClone.EOF) And Not (Len(MyTO) > 20470)
MyField = " "
Do While Len(MyField) > 0
' find all e-mail references with the "enabled" constraint
(available as text. e.g. "(e-mail address removed);enabled")
MyField = DLookup("Entitys_Peculiaritys.Content",
"Entitys_Peculiaritys", " ((Entitys_Peculiaritys.EntityHint = " &
MyRecordsetClone("EntityKey") & ") AND (Entitys_Peculiaritys.PeculiarityHint
= 5) and (Entitys_Peculiaritys.Content like ""*enabled*"") and ( instr(1,"""
& MyTO & """ , Entitys_Peculiaritys.Content ) = 0 ) )")
If MyField > " " Then
MyTO = Replace(Trim(MyTO), ";;", ";") & ";" & MyField & vbCrLf
End If
Loop
MyRecordsetClone.MoveNext
Loop
' remove constraint as text information
MyTO = Replace(Replace(MyTO, " ", ""), ";enabled", "")
If MyTO > " " Then
'send message to the inluded addressees
DoCmd.SendObject acSendNoObject, , , Mid(MyTO, 2, Len(MyTO) - 1), ,
, MySubject, MyBody, True
MsgBox "Over to next blok of mails"
End If
MyRecordsetClone.MoveNext
Loop
Exit Sub
ErrorMsgs:
Select Case Err.Number
Case 2501, 3021
Case 287
MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail" & _
"addresses to send your message. For more information, " & _
"see the document at
http://www.microsoft.com/office/previous/outlook/downloads/security.asp. "
Case Else
MsgBox CStr(Err.Number) & " - " & Err.Description
End Select
End Sub