Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2016
    Posts
    14
    Provided Answers: 1

    Unanswered: Real Progress Bar for long Process

    Hello All,

    i have a VBA Code that send Mails using CDO from a command Btn in Form
    and i'm using inputbox to enter different mails

    PHP Code:
    Private Sub Command1_Click()
        
    Dim Mailto  As String            'Mail To 
        Dim mail    As Object           ' 
    CDO.MESSAGE
        Dim config  
    As Object           ' CDO.Configuration
        
        Mailto = InputBox("Enter Mail", "Enter Email Address")
        
        If Mailto <> "" Then ' 
    if it not empty
        
    MsgBox ("Mail will sent to " Mailto " Press OK and wait for confirmation message "), "Sending ..."
        
    Else
        
    MsgBox "Canceled , or No Mail entered "vbCritical"Error"
       'Terminate if the cancel or empty value is found button is clicked!
        End If


        Set mail = CreateObject("CDO.Message")
        Set config = CreateObject("CDO.Configuration")
        
        config.Fields(cdoSendUsingMethod).Value = cdoSendUsingPort
        config.Fields(cdoSMTPServer).Value = "xxxx"
       
        config.Fields(cdoSMTPServerPort).Value = 465  
        config.Fields(cdoSMTPUseSSL).Value = "true"
        
        config.Fields(cdoSMTPAuthenticate).Value = cdoBasic
        config.Fields(cdoSendUserName).Value = "xxxxx"
        config.Fields(cdoSendPassword).Value = "xxxxx"

        config.Fields.Update
        
        Set mail.Configuration = config
        
        With mail
            .To = Mailto
            .From = "xxxx"
            .Subject = "Test Sub"
            .TextBody = "Test Body."
            .AddAttachment "c:\users\data.bin"
            
            .Send
        End With
        
        Set config = Nothing
        Set mail = Nothing
        If Err.Number = 0 Then
        MsgBox "Message Sent Successfully", vbInformation, "Sent"

    End Sub 
    and it takes time to upload the attachment

    and after about 15 seconds or more ( depends on attach size ) appears a message "Message Sent Successfully " .

    i want a real progress bar starts after entering mail address and finish exactly when a confirmation message appear "Message Sent Successfully "

    something like real file upload progress bar ,
    not a fake progress bar

    thanks in advance

  2. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    470
    Provided Answers: 22
    To use the prog bar, you must know the total amount in order to show the percent.
    Prog.value = amt/total

  3. #3
    Join Date
    Jul 2016
    Posts
    14
    Provided Answers: 1
    Total amount of what??
    Its not a fixed amount over all

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    For you to give meaningful feedback to ysers using a progress bar you have to be able to identify how much work will be done and how much you have done so far. Otherwuse therd is no way of displaying that information to the user

    Assuming you have a orogress bar control, and you want it to dispkaysomethibg meaningfull in a computationaly intensive process (say in a code loop) remember to use the doevents macro otherwise the screen will not refresh

    However for you requirement Im oretty certain you will not fibd a solution as there is no way that Im aware of of knowing what is going on whilst you are sending the email.

    The .send method provides no feedback on how much eork it has to do and how much it has done.
    Last edited by healdem; 07-14-16 at 14:02.
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Jul 2016
    Posts
    14
    Provided Answers: 1
    Like i said before i dont know how much work will be done .
    And its not a fixed amount to tell
    It changes on every mail depends on attachment size

    Lets say i want to see hidden process happens behind this code .

    How is upload or download progres bar work ?
    It calculate amount depending on file size

    How to make this code i used to calculate it automatically?

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    OK
    so first off you need to know the size of the attachment (probably easy enough to know you should be abel to get it fromt eh operating system possible using a file scripting object)

    next you need to know how much of the file has been uploaded. but thats where you idea falls apart. there is no way that Im aware of knowing within Access of how much work another external object has done . You perhaps need to investigate the CDO object to see if it does have a progress level built in.
    but even if it does you then have a problem of how to update the user form with the progress (hint use a timer object)
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Jul 2016
    Posts
    14
    Provided Answers: 1
    Timer based on what?

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    timer controlo in a form can be set to fire off at a specificied interval in milliseconds
    the only other way of doign thsi sort of thins is if say the code is in a loop and update your progress bar (devents) at the end of each stage through the loop


    but this is all irrelevent unless you can find a way of getting from the CDO send email process an indication of how much work it has to do and how much has been done.

    of course you could fake it by timing how long an email of the specified size takes to send,m averaging it out, add say 15..25% to that time then use that as a guesstimate of how long the process will take. run your timer and update the progress bar based on that... but you said you didn't want to fake it
    I'd rather be riding on the Tiger 800 or the Norton

  9. #9
    Join Date
    Jul 2016
    Posts
    14
    Provided Answers: 1
    Yep, not fake!
    If there's no solution for this,
    Is there anyway to send mails like CDO , without outlook or any other third parties app ? Using only Macros or VBA

Posting Permissions

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