Closed Thread
Results 1 to 7 of 7

Disable "a program is trying to..." message

Hybrid View

  1. #1
    Registered User
    Join Date
    12-05-2007
    Location
    Oklahoma
    MS-Off Ver
    2003, 2007
    Posts
    22

    Disable "a program is trying to..." message

    When I run the macro below, I receive the message "A program is trying to automatically send e-mail on your behalf. Do you want to allow this?" My options are yes, no and help and the green progress bar has to go across the warning box before I can click yes. Is there a way to add code in the macro to disable or skip this?

    Sub Send()
        Dim rng As Range
        Dim OutApp As Object
        Dim OutMail As Object
    
        Set rng = Nothing
        On Error Resume Next
        'Only the visible cells in the selection
        Set rng = Selection.SpecialCells(xlCellTypeVisible)
        'You can also use a range if you want
        Set rng = Sheets("Sheet1").Range("A7:D9").SpecialCells(xlCellTypeVisible)
        On Error GoTo 0
    
        If rng Is Nothing Then
            MsgBox "The selection is not a range or the sheet is protected" & _
                   vbNewLine & "please correct and try again.", vbOKOnly
            Exit Sub
        End If
    
        With Application
            .EnableEvents = False
            .ScreenUpdating = False
        End With
    
        Set OutApp = CreateObject("Outlook.Application")
        OutApp.Session.Logon
        Set OutMail = OutApp.CreateItem(0)
    
        On Error Resume Next
        With OutMail
            .To = "TEST"
            .CC = ""
            .BCC = ""
            .Subject = "TEST"
            .HTMLBody = RangetoHTML(rng)
            .Send   'or use .Display
        End With
        On Error GoTo 0
    
        With Application
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub
    Last edited by eriknokc; 03-05-2009 at 08:33 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Disable "a program is trying to..." message

    Hello eriknokc,

    There are 2 options available. You can send the email using CDO (Collaboration Data Objects, previously known as Active Messaging) schema or rewrite the macro to run from Outlook. If you want to run the macro from Outlook you will have to create a digital signature and sign your project before you will be free of all the security b.s.

    If you want to see how it is done using CDO, check out Ron De Bruin's site here

    If you want a VBA example of sending the email from Outlook and how to create a digital signature, download the attached Zipped Word document.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-05-2007
    Location
    Oklahoma
    MS-Off Ver
    2003, 2007
    Posts
    22

    Re: Disable "a program is trying to..." message

    Thanks for the information. When I do that I receive a runtime error -2147220960 (80040220) The "sendusing" configuration value is invalid

    Option Explicit
    
    'This procedure will mail the visible cells in the selection in the body of the mail.
    'Select a few cells first before you run the code
    'You can change it to send a fixed range or the whole worksheet if you want
    
    'Set rng = Sheets("sheet1").Range("D4:D12").SpecialCells(xlCellTypeVisible)
    'Set rng = ActiveSheet.UsedRange
    'Set rng = Sheets("sheet1").UsedRange
    
    
    Sub CDO_Send_Selection_Or_Range_Body()
        Dim rng As Range
        Dim iMsg As Object
        Dim iConf As Object
        '    Dim Flds As Variant
    
        Set iMsg = CreateObject("CDO.Message")
        Set iConf = CreateObject("CDO.Configuration")
        Set rng = Sheets("sheet1").Range("B5:D13").SpecialCells(xlCellTypeVisible)
        Set rng = ActiveSheet.UsedRange
        Set rng = Sheets("sheet1").UsedRange
    
        '    iConf.Load -1    ' CDO Source Defaults
        '    Set Flds = iConf.Fields
        '    With Flds
        '        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        '        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "Fill in your SMTP server here"
        '        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        '        .Update
        '    End With
    
    
        Set rng = Nothing
        On Error Resume Next
    
        Set rng = Selection.SpecialCells(xlCellTypeVisible)
    
        On Error GoTo 0
    
        If rng Is Nothing Then
            MsgBox "The selection is not a range or the sheet is protected" & _
                   vbNewLine & "please correct and try again.", vbOKOnly
            Exit Sub
        End If
    
        With Application
            .EnableEvents = False
            .ScreenUpdating = False
        End With
    
        With iMsg
            Set .Configuration = iConf
            .To = "test"
            .CC = ""
            .BCC = ""
            .From = "test"
            .Subject = "This is a test"
            .HTMLBody = RangetoHTML(rng)
            .Send
        End With
    
        With Application
            .EnableEvents = True
            .ScreenUpdating = True
        End With
    
    End Sub

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Disable "a program is trying to..." message

    Hello eriknokc,

    This is one of the drawbacks in using CDO. It is complicated by many factors. Perhaps this will help you understand what is happening with the field...

    If the SMTP service is installed on the local computer, then the value defaults to cdoSendUsingPickup (1). Otherwise, if Microsoft Outlook Express is installed, the value defaults to cdoSendUsingPort (2) and the settings from the default account are used.

    Field Values
    cdoSendUsingPickup (1)

    cdoSendUsingPort (2)

    cdoSendUsingExchange (3)

    smtpserverport Field
    This field is only relevant when the SendUsing field is set to cdoSendUsingPort (2). The default is 25. What browser are you using? This can effect the port setting.
    Last edited by Leith Ross; 03-06-2009 at 09:06 PM. Reason: Added note about server port numbers

  5. #5
    Registered User
    Join Date
    12-05-2007
    Location
    Oklahoma
    MS-Off Ver
    2003, 2007
    Posts
    22

    Re: Disable "a program is trying to..." message

    I am trying to use this code at work and so that makes sense why I am receiving this error. Thanks for your help in clearing that up.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Disable "a program is trying to..." message

    CDO is my preference also but there are 2 other methods that have not been mentioned:

    1 - Outlook Redemption see: http://www.dimastr.com/redemption/

    2 - ClickYes (3rd Party) see: http://www.contextmagic.com/express-clickyes/
    (the free version should be sufficient)

    Myself, as I say I prefer CDO though I have used ClickYes (without issue) ... I found Redemption a little intense...

  7. #7
    Registered User
    Join Date
    05-13-2010
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    1

    Thumbs up Re: Disable "a program is trying to..." message

    Hi,

    I tried copying digital certificate to the required folder however I got an error while was not clearly understand as it said error only. I have attached the snapshot as well. I am using this on my office PC .Please assist me .

    Regards,
    Knight





    Quote Originally Posted by Leith Ross View Post
    Hello eriknokc,

    There are 2 options available. You can send the email using CDO (Collaboration Data Objects, previously known as Active Messaging) schema or rewrite the macro to run from Outlook. If you want to run the macro from Outlook you will have to create a digital signature and sign your project before you will be free of all the security b.s.

    If you want to see how it is done using CDO, check out Ron De Bruin's site here

    If you want a VBA example of sending the email from Outlook and how to create a digital signature, download the attached Zipped Word document.
    Attached Images Attached Images

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1