+ Reply to Thread
Results 1 to 10 of 10

Problems with outlook application

  1. #1
    Forum Contributor
    Join Date
    01-18-2017
    Location
    Poznań, Poland
    MS-Off Ver
    2016
    Posts
    139

    Problems with outlook application

    Hi there!

    I am preparing the file that allow me to send automatically emails with the right attechment to the right person.

    The file is attached.

    Everything seems to be working perfectly when it runs throught the first record, but when I go any further after second email address (I used Do Until) the error occur next to .BodyFormat

    Could anyone explain me what I have done wrong?
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Problems with outlook application

    Hi Szwadron6,

    The problem appears to be your olEmail object. It should probably be initialized before each time you send an eMail.

    Please Login or Register  to view this content.
    Lewis

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Problems with outlook application

    I think you may need to move this line down:
    Please Login or Register  to view this content.
    right now you create an email, send it and then there is no email to work with until you create a new one...

    Put the above line of code inside the loop, just before
    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Problems with outlook application

    Thanks for marking the thread as solved

  5. #5
    Forum Contributor
    Join Date
    01-18-2017
    Location
    Poznań, Poland
    MS-Off Ver
    2016
    Posts
    139

    Re: Problems with outlook application

    Thank you both for solutions. Now it works just like it is supposed to.

    I have one more question, since I applied all correct emails but now before sending each emails Outlook asks me for approval.

    Is there a way to approve for actions in outlook regarding this code?

  6. #6
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Problems with outlook application

    One workaround (I hate using sendkeys as a rule):
    remove .Send from the earlier part of the email, and then change .Send to .Display and use sendkeys:

    Please Login or Register  to view this content.
    It won't work if you step through the code because the VBA window keeps focus and the %s is not sent to the outlook window, but if you run the code directly then it should work fine.

  7. #7
    Forum Contributor
    Join Date
    01-18-2017
    Location
    Poznań, Poland
    MS-Off Ver
    2016
    Posts
    139

    Re: Problems with outlook application

    Thanks but shall I put this in the end of the whole code or before the loop?

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Problems with outlook application

    Like this:

    Please Login or Register  to view this content.

  9. #9
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Problems with outlook application

    Szwadron6 said:
    ...but now before sending each emails Outlook asks me for approval
    For older versions of Outlook unfortunately, Arkadi's solution is probably correct.

    The following link may help eliminate the message: https://support.office.com/en-us/art...ad=US&fromAR=1


    To prevent the problem from occurring in Outlook 2016:
    To prevent OutLook Security Message such as (and to remain secure):
    a. A program is trying to send an e-mail message on your behalf, or
    b. A program is trying to access e-mail addresses:
    Make sure Anti-Virus software is up to date
    Go to Windows 'Start' Menu
    Right Click on 'Outlook 2016' and select 'Run as Administrator'
    File > Options > Trust Center > Trust Center Settings > Programmatic Access
    AntiVirus status : Valid' should be displayed in the middle of the Screen.

    Lewis
    Last edited by LJMetzger; 02-27-2017 at 01:27 PM.

  10. #10
    Forum Contributor
    Join Date
    01-18-2017
    Location
    Poznań, Poland
    MS-Off Ver
    2016
    Posts
    139

    Re: Problems with outlook application

    Hmmm...
    Not sure what I've done wrong but the result is still the same - outlook asks me for approval before sending each email even though I copied and pasted your whole code directly into vba. I use Run Sub button directly...
    Last edited by Szwadron6; 02-27-2017 at 02:08 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA to Control Outlook Web Application
    By mhartman83 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2014, 03:21 PM
  2. Having Problems with OnTime Application
    By mcb123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-09-2013, 12:13 PM
  3. Application Onkey Problems
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-30-2009, 09:49 AM
  4. Outlook application
    By khanhtt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2006, 03:46 AM
  5. Problems with Application.Inputbox
    By Hernandez, Roberto in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-02-2005, 03:35 PM
  6. [SOLVED] Problems using Application.IgnoreRemoteReferences
    By JGeniti in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-12-2005, 09:05 AM
  7. [SOLVED] Problems with Excel VBA application
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-12-2005, 01:05 PM

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