Consulting

Results 1 to 3 of 3

Thread: New mails are not send until Macro is 'reset'

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    New mails are not send until Macro is 'reset'

    Hi folks,

    I'm using VBA in OUTLOOK for the first time(till now only used it in EXCEL) ....
    I have the following code :

    Sub ScreenAndSend()
    Dim olAPP As Outlook.Application
    Dim olNs As Outlook.NameSpace
    Dim olFolder As Outlook.Folder
    Dim olMailOutput As Outlook.MailItem
    Dim StartTime as Single
    Dim ExtTime as single
    fLoop As Boolean
    ExtTime = 100
    fLoop = true
    While fLoop
        'somewhere in my code :
    Set olMailOutput = Application.CreateItem(olMailItem)
        With olMailOutput
       .To = "<list of e-mail addresses"
       .BCC = "<list of e-mail addresses"
       .Subject = "my subject"
       .BodyFormat = olFormatHTML
       .Body = "content of the mail"
       .Send
       Debug.Print "mail send"
        End with
    StartTime = Timer
        Do While Timer < StartTime + ExtTime
               DoEvents    ' Yield to other processes.
        Loop
    Debug.Print "LOOPED"
    Wend
    End sub
    Everything works fine, including the 'message send' notification.
    But the mail isn't send (that is, they're not arriving at destination) until I stop the VBA code from executing.
    Then the receivers get a mail, with a timestamp equals to the date/time when I stop the code.

    The 'DoEvents'-loop (of 100 seconds) is there to free CPU for other activities.
    I do get the "LOOPED" message after approx 100 seconds, confirming that I get that far.

    Can anyone tell me what I'm forgetting, or doing wrong ?

    Thanks,

    Martin.
    Last edited by Aussiebear; 03-15-2023 at 04:01 PM. Reason: Added code tags to wrap the submitted code

Posting Permissions

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