Results 1 to 11 of 11

Thread: Progress bar to show progress in sending a file using cdo

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    932

    Progress bar to show progress in sending a file using cdo

    I am using a cdo routine to email a file, with complete success. I have placed a progress bar on the main form. Any hints on how I can show the progress of the sending of the file?

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,437

    Re: Progress bar to show progress in sending a file using cdo

    You can't.

    All CDO methods are synchronous. Even if you ran the .Send on another thread there is no way to get any kind of progress event back from it.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    932

    Re: Progress bar to show progress in sending a file using cdo

    Normally I would accept this, despite 'can't' not being in my vocabulary!

    However, when you download eg software you get a progress bar as the download continues. This makes me think that there may be some roundabout way of showing a progress bar as you upload data.

    I happen to know that the file I will be sending takes 1.5 minutes to upload normally. If there is some way to run a parallel thread that simply increments the value of the progress bar in step with elapsed time (the code for so incrementing being of course trivial), that would do

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,437

    Re: Progress bar to show progress in sending a file using cdo

    When you download software you are not using CDO though, are you?

    About all you could do is have the CDO.Send run on a worker thread (using an ActiveX EXE) while your UI thread uses a Timer to bump a bogus progress bar until the Send completes.

    As I said it is synchronous and doesn't do callbacks or other progress notification. If you want that you will have to obtain some 3rd party SMTP client library that offers all of the features you need plus progress notifications.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    932

    Re: Progress bar to show progress in sending a file using cdo

    Quote Originally Posted by dilettante View Post

    About all you could do is have the CDO.Send run on a worker thread (using an ActiveX EXE) while your UI thread uses a Timer to bump a bogus progress bar until the Send completes.
    I'd like to pursue that! Might need a bit of code!

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    932

    Re: Progress bar to show progress in sending a file using cdo

    Here's the code I'm using ('blah' used to preserve privacy and passwords).

    With New cdo.Message 'outer with loop
    With .Configuration.Fields 'inner with loop
    .Item(cdoSendUsingMethod).Value = cdoSendUsingPort
    .Item(cdoSMTPServerPort).Value = 25
    .Item(cdoSMTPServer).Value = "blah"
    .Item(cdoSendUserName).Value = "blah"
    .Item(cdoSendPassword).Value = "blah"
    .Item(cdoSMTPAuthenticate).Value = cdoBasic
    .Item(cdoImportance) = cdoHigh
    .Item(cdoPriority) = cdoPriorityUrgent
    .Update
    End With ' end inner with loop
    ProgressBar1.Value = 10
    .From = """blah"" blah@blah>"
    .To = """blah""blah@blah" 'will be blah
    .CC = """blah""blah@blah" 'will be blah
    .Subject = "URGENT blah Files!"
    ProgressBar1.Value = 20
    .TextBody = EmailText & vbNewLine & StdEmail & vbNewLine & vbNewLine & "blah"
    .AddAttachment "C:\users\blah.zip"
    On Error Resume Next
    .Send
    ProgressBar1.Value = 100
    End With 'end outer with loop
    '######### remove this block when all running OK and just leave confirmation without if.
    If Err.Number <> 0 Then
    MsgBox "CDO error " & Hex$(Err.Number) & vbNewLine & Err.Description, _
    vbOKOnly Or vbExclamation
    Else
    Label4.Caption = ""
    MsgBox "Mail sent!", vbOKOnly
    End If

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,437

    Re: Progress bar to show progress in sending a file using cdo

    If you think a fake progress bar is going to be useful to you then you might read up on creating and using ActiveX EXE projects. The VB6 documentation has the information you'll need as well as a tutorial.

    There are lots of things to consider, not the least of which being the risk of cluttering the registry with hard to clean junk. If you have to ask then you probably need another answer.

    I don't think you'll be happy with the result after all the work anyway. You need to use something else instead of CDO SMTP, something more like MailMan that has a progress event.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    932

    Re: Progress bar to show progress in sending a file using cdo

    Now wondering whether I should change the whole thing to Mailman. Certainly don't want to clutter the registry.

  9. #9
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,480

    Re: Progress bar to show progress in sending a file using cdo

    Anyone know if the common-controls Marquee progress bar runs in a different thread or not? That may be an option. Another option could be TaskDialog with its Marquee dialog (Vista+).

    Granted, Marquee dialogs are pretty much the same as the old Win95 snare drums or the old-fashioned animated hourglass cursor.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  10. #10
    PowerPoster
    Join Date
    Jun 2013
    Posts
    4,930

    Re: Progress bar to show progress in sending a file using cdo

    What about re-shelling your own App (with an appropriate CommandLine-param)?

    In your Sub Main() you could then check the Command$-Variable, and react appropriately
    (either showing your GUI, or silently uploading an E-mail per CDO, occasionally updating
    for example a DB-Table which described the current Job, and has a SendStatus-Field).

    Polling this DB-Table from your Main-(GUI-) process any second or so, will not cause
    any measurable System-Load.

    Olaf

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2012
    Posts
    932

    Re: Progress bar to show progress in sending a file using cdo

    Both of those kind suggestions are little over my head! Unless I can code this simply it probably is not worth the effort. More detailed suggestions welcome if they are fairly simple.

Posting Permissions

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



Click Here to Expand Forum to Full Width