sendobject

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
 
J

Joan Wild

From a previous answer from Sue Mosher, Outlook MVP...
<q>
"The security dialogs that pop up when an application tries to access
certain Outlook properties and methods are designed to inhibit the spread of
viruses via Outlook; see
http://www.slipstick.com/outlook/esecup.htm#autosec. If you are a standalone
user, Outlook provides no way to suppress this behavior. However, you can
use a free tool called Express ClickYes
(http://www.express-soft.com/mailmate/clickyes.html) to click the security
dialog buttons automatically. Beware that this means if a virus tries to
send mail using Outlook or gain access to your address book, it will
succeed.


"If you're the administrator in an Exchange Server environment, you can
reduce the impact of the security prompts with administrative tools. See
http://www.slipstick.com/outlook/esecup/admin.htm


"If it's an application you wrote yourself, you can use one of these
approaches to redo the program:


-- Use Extended MAPI (see http://www.slipstick.com/dev/mapi.htm) and C++
or Delphi; this is the most secure method and the only one that Microsoft
recommendeds.


-- Use Redemption (http://www.dimastr.com/redemption/), a third-party
COM library that wraps around Extended MAPI but parallels the Outlook Object
Model


-- Use SendKeys to "click" the buttons on the security dialogs that your
application may trigger. See
http://www.slipstick.com/outlook/esecup.htm#autosec for a link to sample
code.


-- Program the free Express ClickYes
(http://www.express-soft.com/mailmate/clickyes.html) tool to start suspended
and turn it on only when your program needs to have the buttons clicked
automatically."
<end quote>


--
Joan Wild
Microsoft Access MVP
: 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
:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top