Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2009
    Location
    Norway
    Posts
    2

    Unanswered: Annoying message: "A program is trying to send an attachment.....

    MAPI security prompts the user for each email to verify its okay.

    "A program is trying to automatically send e-mail on your behalf. Do you want to allow this? If this is unexpected, it may be a virus and you should oose "No"."


    I'm using cmd.sendobject to send email with attachment fraom Access 2003 VBA, but this annoying message repeats itself for each mail.

    I see that many can cope with this message from Outlook, but I want to send some hundred e-mails with attachments.

    I have read in another website that this message should come only once (not using Outlook). This had been acceptable for me too, but I hope that anyone could have an idea about how to suppress this message.

    Is it the method used in VBA?
    Are there any option settings in Outlook?

    I hav seen the explanation, but it doesn't fit in Outlook:
    "The second problem is caused by a security setting in Outlook that Microsoft put in after the outbreak of viruses that emailed themselves to everyone in your Outlook address book. To turn it off, open Outlook (Express) and pick Options from the Tools menu, then click the Security tab, then uncheck "Warn me when applications try to send mail as me."

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    It's an outlook security feautre that you cannot bypass.

    You can, however, bypass outlook entirely.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    If you use Outlook automation rather than sendobject, you can open the email after it's been created and use sendkeys to 'push' the send button. The user can't use the PC while it's running, but it goes pretty fast and they don't have to sit and click to send each email.

  4. #4
    Join Date
    Mar 2009
    Location
    Norway
    Posts
    2

    Outlook automation?

    Quote Originally Posted by rogue
    If you use Outlook automation rather than sendobject, you can open the email after it's been created and use sendkeys to 'push' the send button. The user can't use the PC while it's running, but it goes pretty fast and they don't have to sit and click to send each email.
    It was nioce to hear that there are ways to get around this problem.
    Could you please tell me how to use Outlook automation and sendkeys?

    Many thanks in advance.

  5. #5
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    This is the code I use. You should be able to modify it to suit your needs. Post back with any questions.

    Private Sub cmdSendEmail_Click()
    Dim objOutlook As Outlook.Application
    Dim objMailItem As Outlook.MailItem
    Dim strSubject As String
    Dim strBody As String
    Dim strAttch As String
    Dim blnAttch As Boolean
    Dim intJV As Integer
    Dim rstEmail As DAO.Recordset

    'LOOP THROUGH A RECORDSET TO SEND AN EMAIL TO EACH RECORD
    Set rstEmail = CurrentDb.OpenRecordset("qrySendEmail")
    rstEmail.MoveLast
    rstEmail.MoveFirst

    intJV = 0
    For intJV = 0 To rstEmail.RecordCount - 1

    'SET THE EMAIL BODY HERE AS strBody

    'IF YOU HAVE AN ATTACHMENT SET blnAttach to True and strAttach to the path/filename of of the attachment


    Set objOutlook = New Outlook.Application
    Set objMailItem = objOutlook.CreateItem(olMailItem) '

    With objMailItem
    .To = rstEmail!Email 'recipient's address from field Email in query qrySendEmail
    .Subject = strSubject
    .Body = strBody
    If blnAttch = True Then
    .Attachments.Add strAttch
    End If
    .Display
    SendKeys "%{s}", True
    End With

    Set objMailItem = Nothing
    Set objOutlook = Nothing

    rstEmail.MoveNext
    Next intJV

    End Sub

  6. #6
    Join Date
    Jan 2007
    Location
    Pennsylvania
    Posts
    8
    I am using similar code to send email from Access and it works great. However, I need to write data relating to the email (recipient, date, etc.) to a table. I have that working too, but if the user clicks "no" to send the email, I can't suppress the code that writes the record. Does anyone have any suggestions on how to handle this? Thank you.

  7. #7
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    That's one quick user!! When I've seen that bit of code run, it's generally a quick flash on the the screen before the email goes out.

    The only thing I can think of would be to send all the emails then check the 'Sent' folder in Outlook to determine which records to write or update. After the email routine runs, open the 'Sent' folder, loop through the contents (possibly filtering by time sent or subject line), grab the recipient email and write or update the record(s) as needed.

  8. #8
    Join Date
    Jan 2007
    Location
    Pennsylvania
    Posts
    8
    Quote Originally Posted by rogue View Post
    That's one quick user!! When I've seen that bit of code run, it's generally a quick flash on the the screen before the email goes out.

    The only thing I can think of would be to send all the emails then check the 'Sent' folder in Outlook to determine which records to write or update. After the email routine runs, open the 'Sent' folder, loop through the contents (possibly filtering by time sent or subject line), grab the recipient email and write or update the record(s) as needed.
    The message box appears on the screen with yes / no / cancel as options. Yes must be checked to send the email. I'd like to capture that event but since it's not my code, I can't.

    Your suggestion about accessing the Sent folder is interesting. I'll look into it. Thank you.

  9. #9
    Join Date
    Apr 2004
    Location
    metro Detroit
    Posts
    634
    It sounds like you're not using the .display and send keys bit to automatically send the email. If you want the user to be able to send the email or not send the email, you could set up your own message box to ask the user if they want to send an email. If they click 'Yes', run the code to automatically send it and update the record.

  10. #10
    Join Date
    May 2010
    Posts
    601
    I would avoid using sendkeys. It has issues and very prone to problems.

    Check out:

    ClickYes Software. Get rid of annoying Outlook messages.


    To really bypass it see:

    Outlook Redemption


    This may also be helpful:

    Outlook "Object Model Guard" Security Issues for Developers
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  11. #11
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267
    I just use CDO with great results. Here's some code that I use. I just create an HTML formatted string for the body and pass that to the function.

    Code:
    Public Function SendEmail(pFrom As String, pTo As String, pSubj As String, _
        Optional pBody As String, Optional pAttach As String) As Boolean
        
        On Error GoTo ErrHandler
    
        Dim objMessage As Object
    
        Set objMessage = CreateObject("CDO.Message")
        objMessage.From = pFrom
        objMessage.To = pTo
        objMessage.Subject = pSubj
        objMessage.HTMLBody = pBody
        
        If pAttach <> "" Then objMessage.AddAttachment pAttach
         
        objMessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        
        'Name or IP of Remote SMTP Server
        objMessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = EnterYourServerHere
        
        'Server port (typically 25)
        objMessage.Configuration.Fields.Item _
        ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        
        objMessage.Configuration.Fields.Update
    
        objMessage.Send
        
        'if made it here then email was sent
        SendEmail = True
        
    ExitHere:
        Set objMessage = Nothing
        Exit Function
        
    ErrHandler:
        SendEmail = False
        Resume ExitHere
    End Function
    C

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •