|
-
Nov 6th, 2000, 03:46 PM
#1
Thread Starter
Fanatic Member
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
-
Nov 6th, 2000, 04:55 PM
#2
Hyperactive Member
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: 
-
Nov 6th, 2000, 07:20 PM
#3
Thread Starter
Fanatic Member
-
Nov 7th, 2000, 12:03 PM
#4
Thread Starter
Fanatic Member
I hate to bring this one to the floor again but does anyone have an idea on this one....
-
Nov 7th, 2000, 12:15 PM
#5
Addicted Member
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
-
Nov 7th, 2000, 12:16 PM
#6
Fanatic Member
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?
-
Nov 7th, 2000, 01:01 PM
#7
Thread Starter
Fanatic Member
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
-
Nov 7th, 2000, 01:25 PM
#8
Thread Starter
Fanatic Member
When I put a common in it wants to specify the window size eg vbnormal, etc.
-
Nov 7th, 2000, 02:24 PM
#9
Thread Starter
Fanatic Member
-
Nov 7th, 2000, 02:36 PM
#10
Frenzied Member
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.
-
Nov 7th, 2000, 02:49 PM
#11
Thread Starter
Fanatic Member
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?
-
Nov 7th, 2000, 03:26 PM
#12
Frenzied Member
Try this:
If clemail is located in your system's path, then this should work:
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]
-
Nov 7th, 2000, 03:28 PM
#13
Black Cat
Shell("Whatever") is a double. Therefore, you are concatenating strings to a double.
Josh
-
Nov 7th, 2000, 03:40 PM
#14
Frenzied Member
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.
-
Nov 7th, 2000, 03:47 PM
#15
Frenzied Member
Its possible via winsock if you want to go down that path.
-
Nov 7th, 2000, 03:51 PM
#16
Thread Starter
Fanatic Member
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...
-
Nov 7th, 2000, 06:03 PM
#17
Thread Starter
Fanatic Member
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....
-
Nov 8th, 2000, 08:05 AM
#18
Black Cat
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
-
Nov 8th, 2000, 10:47 AM
#19
Thread Starter
Fanatic Member
How would you do it via winsock?
-
Nov 8th, 2000, 11:01 AM
#20
Fanatic Member
Originally posted by brianh
How would you do it via winsock?
http://www.vbsquare.com/articles/sendmail/
-
Nov 8th, 2000, 12:22 PM
#21
Addicted Member
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.
-
Nov 8th, 2000, 12:29 PM
#22
Thread Starter
Fanatic Member
Could you give an example of that? code....
-
Nov 8th, 2000, 12:31 PM
#23
Frenzied Member
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
-
Nov 8th, 2000, 12:41 PM
#24
Frenzied Member
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.
-
Nov 9th, 2000, 12:29 AM
#25
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|