Results 1 to 25 of 25

Thread: Email and VB

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    I have found a program on the net that allows you to send emails via the command line (DOS). All you have to do it cd into the proper directory and then type the exe (clemail) and then put certain switches after that. Such as:

    clemail -smtpserver (the name of your smtp server) -from (whoever it is from) etc

    What I would like to do is write a sub that uses the shell command to call that exe. I then would cancatanate specific text boxes and combo boxes to fill in the information. I have tried this but have been unsuccesful. The following is a piece of code that I have tried to use but does not work.

    ____________________________________________________________
    Shell ("g:\digisend\digi\clemail\clemai.exe null") & "-quiet" & "-smtpserver *********" & "-from Digital Sender" & _
    "-subject" & txtnameofodoc.Text & "-body Attached is a file from the digital sender application" & _
    "-attach g:\q\" & txtcboquery.Text & "-to" & txtemail.Text
    ____________________________________________________________

    Does anyone have any other ideas? Is the shell command best to use or should I use something else?

    Thank you

  2. #2
    Hyperactive Member D12Bit's Avatar
    Join Date
    Oct 2000
    Location
    Guatemala
    Posts
    373

    Lightbulb How about this...

    Have you tried this...?
    Code:
    Shell ("g:\digisend\digi\clemail\clemai.exe null" & "-quiet" & "-smtpserver *********" & "-from Digital Sender" & _ 
    "-subject" & txtnameofodoc.Text & "-body Attached is a file from the digital sender application" & _ 
    "-attach g:\q\" & txtcboquery.Text & "-to" & txtemail.Text)
    Just pay attention where do you finish the parameters of a
    function, because you should send all the necessary data to
    the Shell() function, this includes the parameters of the
    application that you are launching...

    Saludos...

    [email protected]?Subject=Hi, how are you
    "Who Dares Wins" - "Quien se Arriesga Gana"
    Mail me at:

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Any suggestions??

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    I hate to bring this one to the floor again but does anyone have an idea on this one....

  5. #5
    Addicted Member
    Join Date
    Aug 2000
    Location
    Columbus Ohio
    Posts
    217

    Yes

    The prob is you can't put the switches IN the app path, after you type where it is, press comma to get to the next field for the function and type the switches there
    Chris

    [email protected]
    Windows XP RC2 B2526
    Visual Studio.Net Beta 2
    C++, VB, VB.Net, ASP, PHP

  6. #6
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    A few questions:
    1) does there need to be the null in the commandline?
    2) does there have to be spaces before and after each switch?
    3) does there have to be quotes around the subject, body, etc?
    -Excalibur

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Thanks for the reponse:

    1) I am not sure abou the null statement. I put that there because in the shell function you specify the file name after after the path to the exe. That is why I have null there because I am opening an exe with parameters not a document.

    2) I am not sure about the spaces. Any suggestions

    3) I believe that I do need the info on the quotes, won't VB take that as actual coding if I don't??

    Do you want me to email to application and documentation for the command line email??

    Thank you

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    When I put a common in it wants to specify the window size eg vbnormal, etc.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Any suggestions??????

  10. #10
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Arrow Some thoughts...

    Why don't you post the exact command line text that you type at the DOS prompt (EXACTLY as you would type it, i.e. spaces, quotes, NULL(?), etc.)?

    If you know the syntax that WORKS at the command line (I assume you have tried it and it works from the "Run" dialog or the DOS prompt) we should be able to help you.

    This shouldn't be too tough.
    ~seaweed

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    I tried that. Here is the syntax

    clemail -smtpserver ****** -to [email protected] -subject subject -body test -from [email protected] -attach text.txt

    This will send an email to the spec. email address, with a file attached (text.txt) from [email protected] with the subject being subject and the bosy being test

    The following is what I put in the VB app.

    Shell ("G:\DigiSend\digi\CLEMAIL\clemail.exe") & -quiet & -smtpserver ******** & -from Digital Sender & _
    -subject & txtnameofodoc.Text & -body Attached is a file from the digital sender application & _
    -attach g:\q\ & txtcboquery.Text & -to & txtemail.Text

    When I do this it stops at the smtpserver (I have the address there but for privacy reasons I have put the astericks). It then states expected: end of statement.

    Any suggestions?

  12. #12
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Try this:

    If clemail is located in your system's path, then this should work:
    Code:
    Shell ("clemail -smtpserver ****** -to [email protected] " & _
           "-subject subject -body test -from [email protected] " & _
           "-attach text.txt")
    Otherwise try this:
    Code:
    Shell ("G:\DigiSend\digi\CLEMAIL\clemail.exe -smtpserver ****** " & _
           "-to [email protected] -subject subject -body test " & _
           "-from [email protected] -attach text.txt")
    If that works then this should work for your program:
    Code:
    Shell ("G:\DigiSend\digi\CLEMAIL\clemail.exe -quiet -smtpserver *********" & _
           " -from Digital Sender -subject " & txtnameofodoc.Text & _
           " -body Attached is a file from the digital sender application" & _
           " -attach g:\q\" & txtcboquery.Text & " -to" & txtemail.Text
    This is similar to a previous post, except they didn't put the spaces in between the switches (where the strings were concatenated.

    Tell me if that works...

    [Edited by seaweed on 11-07-2000 at 03:41 PM]
    ~seaweed

  13. #13
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Shell("Whatever") is a double. Therefore, you are concatenating strings to a double.

    Josh

  14. #14
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Exclamation Uh, no, Josh, that's not correct

    The Shell function RETURNS a double, which is the TaskId of the Program it executes. The first (and only required) argument is a STRING, which is the path of the program you want to execute.

    The problem (I think) with the string concatenation in D12Bit's post is that he didn't put any spaces between the switches.
    ~seaweed

  15. #15
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Its possible via winsock if you want to go down that path.

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    I did the coding like you stated and when I ran it it gave me no error message. This is a good sign but I have to wait for the email..... Thanks for the help and please watch this thread. I will update it...

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    I tried the method of filling all of the information in the parathenses and getting rid of the &'s. It did not give me an erro message but I have not received an email yet....

  18. #18
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    The Shell function RETURNS a double, which is the TaskId of the Program it executes. The first (and only required) argument is a STRING, which is the path of the program you want to execute.
    Yeah, I know you're right, seaweed, but my weird way of thinking equates returning a value to being a value.

    Code:
    Dim x As Double
    x = Shell("notepad") + Shell("winver")
    MsgBox x / 7
    Also, as PsyVision said, it's doable via winsock if you want to learn a little smtp.

    Josh

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    How would you do it via winsock?

  20. #20
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Originally posted by brianh
    How would you do it via winsock?
    http://www.vbsquare.com/articles/sendmail/
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  21. #21
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    Normally, the Shell function does not admit any space or parameter in the command line. I think all you need to do is to use Chr$(34) to enclose whatever in the command line. If you have not yet succeeded in that, try something like this:

    Shell ¡°exe name including path plus an ending space¡± & Chr$(34) & ¡°all the parameters including the email file¡± & Chr$(34)

    Hope it helps.

  22. #22

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Seattle
    Posts
    954
    Could you give an example of that? code....

  23. #23
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Question Where did you get that information???

    Normally, the Shell function does not admit any space or parameter in the command line.
    That is news to me. Where did you get this info?

    I have used the shell function to register and unregister ocx's, which DOES accept spaces (there is a space between regsvr32 and the name of the ocx you want to register/unregister) AND switches (you need to use the "/u" switch to unregister).

    Example:
    Code:
    Option Explicit
    
    ' Command1 Unregisters aniglass, and Command2 registers it again.  This works fine.
    
    Private Sub Command1_Click()
        Shell "regsvr32 /u aniglass.ocx"
    End Sub
    
    Private Sub Command2_Click()
        Shell "regsvr32 aniglass.ocx"
    End Sub
    ~seaweed

  24. #24
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    What the Shell function really does...

    In case you were wondering, the shell function acts like the "Run" dialog box (Start/Run...). Whatever you have in quotes as an argument to shell will work the same as if you typed it into the "Run" dialog. Try it out and see.

    If you want to shell an application, just type the name of the app (Shell "notepad.exe"). If you want to open up a specific file, for example "temp.txt" you put a space between the application that opens it and the file name (Shell "notepad.exe C:\Windows\Desktop\temp.txt").

    This works the same if you type it into the Run dialog box.

    Just thought that was interesting, and that if you can make your mail program work on the Run command line, you should be able to type the same text into the Shell command and get the same results.
    ~seaweed

  25. #25
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138

    Re: Where did you get that information???

    [QUOTE]Originally posted by seaweed
    That is news to me. Where did you get this info?


    I didn¡¯t get that info anywhere. I have got it from experience. Create a Word document file in a long directory and try something like the following and you¡¯ll see:

    Shell "c:\Program Files\Microsoft Office\Office\Winword.exe C:\Program Files\Outlook Express\HelpVb.doc",vbMaximizedFocus

    vs.

    Shell "c:\Program Files\Microsoft Office\Office\Winword.exe " & Chr$(34) & "C:\Program Files\Outlook Express\HelpVb.doc" & Chr$(34), vbMaximizedFocus

    And for your specific case I suggest a code like this ¨C I haven¡¯t tried it for I don¡¯t have an email app as you have:

    Code (Note the space following .exe AND I don't know how to use the line end continuing character in such a long command OR even whether it is proper.):
    ---------------------------------------------------
    Shell "g:\digisend\digi\clemail\clemai.exe " & Chr$(34) & "-quiet -smtpserver *********" -from Digital Sender -subject txtnameofodoc.Text -body Attached is a file from the digital sender application -attach g:\q\ txtcboquery.Text -to txtemail.Text¡± & Chr$(34)
    ---------------------------------------------------

    Good luck.
    If you still cannot manage with this, I have no other way out either.



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