Results 1 to 6 of 6
  1. #1
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194

    Slow Email (Outlook) only if email needs input (not auto send)

    Hi again.



    Every time i get something running another issue comes up!! SOOO CLOSE!

    lol

    So I got my email system running.

    I use the email object not the sendobject (Set oEmailItem = oOutlook.CreateItem(olMailItem))

    BUT i have tried this with both methods!

    I get the email up and type in the email address (outlook) then press send.

    The 'windows thinking' icon comes up over the mouse pointer and it takes about 15-20 secs to email the item.

    If i use the Outlook.Createitem and just put the address as oemailItem.TO = hello at google dot com Then i can send about 30 emails in a second using exactly the same report in a loop...

    I'm getting an error 0 with no text when it finishes running and it DOES send the email, but i dont get why it sits there and thinks for so long first!

    Any ideas? or directions i can look and read?

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    There are dozens of ways to approach this. My preference is to use early binding and make as many declarations as possible. This goes with Automation of most any application, Outlook, Excel, Acrobat, etc. Here is a code snippet that may be useful to you. I mention early binding and declarations because this tells the PC to reserve a specific amount of RAM prior to executing the code that will use the RAM. Otherwise, the procedure may cause the PC to reserve an unnecessary amount of memory.

    https://www.accessforums.net/import-...tml#post281258


    .

  3. #3
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    wow thats great. worked a treat.

    Now just to send some kind of naming criteria over from the report so that the naming of the exported file is dynamic.

    This is a function that runs off a right click "send email" custom shortcut.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Cool, sounds like you have it covered. Let us know if you hit a roadblock or something was not clearly explained.

  5. #5
    gangel is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2014
    Posts
    194
    thanks again.

    I do have it covered, but i dont totally understand WHY this works better.?

    Is it.. because you attached it early before the actual event, then the program knows how much memory to allocate to Outlook when it opens?

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I have not seen your code so I cannot explain why your code was causing a slowdown of your system. It is common to use late binding and to use variables that are larger (require a lot of memory) than they need to be.

    When possible, you want to use the New keyword in your declarations. Also, you want to explicitly declare the type. When you choose a type, your choice should be one that best fits the situation. You do not want everything to be Object when you need Application or MailItem.

    In short, Access does not have to guess what type to use and this is where the optimization occurs.

    Code:
    'Reference Microsoft Outlook and
    'use early binding
    Dim objOutlook As New Outlook.Application
    Dim objNewEmail As MailItem
    Dim objAttachReport As Attachments
    
    'Instantiate your objects
    Set objNewEmail = objOutlook.CreateItem(olMailItem)
    Set objAttachReport = objNewEmail.Attachments

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 07-21-2015, 05:27 AM
  2. How to send formatted email without outlook
    By alex1888 in forum Programming
    Replies: 2
    Last Post: 06-04-2015, 08:32 PM
  3. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  4. Send email in Outlook with attachment
    By kelkan in forum Programming
    Replies: 1
    Last Post: 02-01-2013, 10:31 PM
  5. Send email from Access thru Outlook
    By ZMAN in forum Forms
    Replies: 2
    Last Post: 11-27-2010, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums