Consulting

Results 1 to 9 of 9

Thread: Disabling Outlook alert

  1. #1
    VBAX Regular
    Joined
    Jul 2005
    Posts
    74
    Location

    Disabling Outlook alert

    I'm sending an excel sheet attached to an email through Outlook

    [VBA]
    ActiveWorkbook.SendMail Recipients:=names
    [/VBA]

    I recieve an alert notifying me that an application is attempting to send an automated email. It must be confirmed before the email is sent. Any way to not get this alert??

  2. #2
    VBAX Expert
    Joined
    Jul 2004
    Location
    Wilmington, DE
    Posts
    600
    Location
    This is actually a safety enhancement to try and prevent malicious code from propagating itself through your email.

    If you want to be able to use the SendMail method, which can be handy, then I recommend using ClickYes:
    http://www.contextmagic.com/express-clickyes/

    Other alternatives include using the CDO library, or using the Redemption library:
    http://www.dimastr.com/redemption/

    Patrick

  3. #3
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location
    You can use a send key method. Take this example below.


    [VBA]
    Sub Send_Test()
    Dim objol As New Outlook.Application
    Dim objmail As MailItem
    Set objol = New Outlook.Application
    Set objmail = objol.CreateItem(olMailItem)
    With objmail
    .To = "Anybody@home.com"
    .Subject = "Who/Me"
    .Body = ""
    .NoAging = True
    .Attachments.Add "C:\A test.xls"
    .Display
    End With
    Set objmail = Nothing
    Set objol = Nothing
    SendKeys "%{s}", True

    End Sub
    [/VBA]

  4. #4
    VBAX Expert
    Joined
    Jul 2004
    Location
    Wilmington, DE
    Posts
    600
    Location
    Quote Originally Posted by Shazam
    You can use a send key method.
    But that would still trigger the security alert. The alert pops up whenever another app tries to touch the Outlook object model.

    Patrick

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Hi,

    To just send an email without any user interaction, you need Outlook Redemption. Google it on the web. For help, check out www.slipstick.com or Sue Mosher's site www.outlookcode.com.

    I prefer to send email using late binding personally. Check out kpuls site on late binding here: http://www.excelguru.ca/XLVBA/XLVBA08.htm, or post back if you need an example.

  6. #6
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location
    Send key method is a key stroke. It should by pass the security alert. I've tested it and it does by pass it.

  7. #7
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    I would not recommend using SendKeys whatsoever. It's too volatile of an action.

  8. #8
    VBAX Expert Shazam's Avatar
    Joined
    Sep 2005
    Posts
    530
    Location
    I never had a problem using it. what are the potential problems might occur?

  9. #9
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Timing, slow apps, stepping through, debugging, the list goes on. If you can stray away from it, I would.

Posting Permissions

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