Solved

Sending mail from Command prompt

Posted on 2001-09-05
25
192 Views
Last Modified: 2010-04-13
Hi,

I am sending out a CD to many users. I am creating a simple batch file which will copy the contents onto their hard drive.

I would like to include a confirmation email. This email should get sent after the copy, so that I know which users have completed the copy.
The users may not have outlook open, and they may not even be connected to the server at that time.

Is there a way I can create the email from the batch, and send it? (Note that sending it, really just puts it in the outbox, ready for the next time they connect).

Thanks for any tips,
RDR
0
Comment
Question by:rderidder
  • 10
  • 6
  • 3
  • +4
25 Comments
 
LVL 25

Expert Comment

by:dew_associates
Comment Utility
I'm a bit confused here. You say you are sending a CD to many users, therefore I presume that you are physically mailing it. Do I also presume that once they do the installation, you want the installer to notify you by email that they have completed that operation?

Dennis
0
 
LVL 44

Expert Comment

by:CrazyOne
Comment Utility
Also there is a presumption here that all the users are using Outlook. What if they are using OE or Netscape or some other email client. Also are you informing the user that you are going to be doing this? If you are not informing them that you are going to be doing this then I think there is a question about ethics here and privacy issues. Quite frankly I don't think this can be accomplished with a batch file per se. To many variables involed to quarantee any degree of success. This sounds like something that would need to be ran with a script or an exe file using MAPI functions.


Hi Dennis


The Crazy One
0
 
LVL 4

Expert Comment

by:andydis
Comment Utility
MAILTO:user@domain.com

usually works in a bat file
start MAILTO:user@domain.com

however if you wnat to send it then you are going to have to wrtie something a little better than a batch file...

why not have the bat file call a vbs file? with the echo command it can be done?
0
 

Author Comment

by:rderidder
Comment Utility
All users are on Outlook.
All users have been notified of the process.

I have been told by someone to look at Q151670, but as yet, I don't know what topic area, and searching on that doesn't seem to work.

Dennis - you are correct

Thanks
RDR
0
 
LVL 25

Expert Comment

by:dew_associates
Comment Utility
RDR, you would probably be better off posting this in the VBS or a scripting area rather than try and batch it.
0
 

Author Comment

by:rderidder
Comment Utility
I don't mind using the MAILTO, and having the user press the send button... Have to test it out..(Does it queue the message until the user is connected, or will it error?)

Can I put the subject and body info in it at all?
I will look into MAILTO..

0
 

Author Comment

by:rderidder
Comment Utility
mapisend.exe was suggested also.. Looking into that too..
0
 
LVL 44

Expert Comment

by:CrazyOne
Comment Utility
Thanks for the clarification rderidder. I agree with Dennis this would work better with a srcript overall and the VB forum may better serve you on this. I don't think a batch file would be queued but I never tried it.
0
 
LVL 10

Accepted Solution

by:
Longbow earned 100 total points
Comment Utility
'--- Beginning of Sendmail.vbs ---
'This only ork with Outlook installed.
'Put all of this script in a .vbs file.
'Script wich send a file attach and copy files.
'Requirement : VbScript Engine (in MSIE5 or http://msdn.microsoft.com/scripting)
'You need to change variables in third paragraph to suit your needs.
'

Dim objOutlook
Dim objNameSpace
Dim mItem
Dim strReceipient
Dim strSubject
Dim strBodyText
Dim strMsg
Dim pAttachment
Dim strAttach
Const olMailItem = 0

'Modify the three next variables as needed and the paths in the last paragraph.
strSubject = "Enter Subject Line."
strRecipient = "xxx@yyy.com"
strBodyText = "Message text : Wow!" & VbCrLf & "This really works!" & VbCrLf

   Set objOutlook = CreateObject("Outlook.application")
   Set objNameSpace = objOutlook.GetNamespace("MAPI")
   Set mItem = objOutlook.CreateItem(olMailItem)
   
   mItem.To = strRecipient
   mItem.Subject = strSubject
   mItem.Body = strBodyText
   
   mItem.Save
   mItem.Send
   
   If strRecipient = "" Then
     Msgbox "No Recipient provided.  Mail not sent", vbInformation,"Mail Error"
   End If

   Set mItem = Nothing
   Set objNameSpace = Nothing
   set objOutlook = Nothing
'--- End of Script ---

run a command like "if exist file.iso cscript sendmail.vbs"
0
 

Author Comment

by:rderidder
Comment Utility
Will this queue the mail if the user is not currently connected?
0
 
LVL 10

Expert Comment

by:Longbow
Comment Utility
If you absolutely need a batch try this.
Body will be on only one line.
And actually i have no solution to press the Send button but in VBScript.

I will search to use mapi with VBScripts. Maybe have you posted in the VB thread...

--- beginning of batch ---
set muser=XXX
set musercc=YYY
set msubject="here my subject"
set mbody="body message"

start mailto:%muser%?cc=%musercc%&subject=%msubject%&body=%mbody%

rem to create your mailto use this URL
--- end of batch ---
0
 

Author Comment

by:rderidder
Comment Utility
It isn't much of a difference for me... Unless only one of them will queue the mail if the user is not currently connected...

RDR
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 10

Expert Comment

by:Longbow
Comment Utility
It opens Outlook and send the mail immediately.
I think Outlook will open the connection ?
Sorry, i have not read all the posts.
I need to save the info in a file and check the connection is open or not.
Maybe checking some TCP/IP settings like the IP ?

Have someone an idee ?
0
 

Author Comment

by:rderidder
Comment Utility
It isn't much of a difference for me... Unless only one of them will queue the mail if the user is not currently connected...

RDR
0
 

Author Comment

by:rderidder
Comment Utility
Outlook will queue it until it can send it... Thats good enough for me. As long as it actually opens outlook, and puts the message in the outbox.

Thanks
0
 
LVL 4

Expert Comment

by:darrenburke
Comment Utility
here is a FREEWARE utility called COMMAIL that I use all the time.  It works great

http://www.xwebware.com/products/commail/


 Here are a list of valid command parameters:

  -help
  -host=<SMTP Server>
  -from=<Your Email Address>
  -to=<Receipient's Email Address>
  -bcc=<Receipient's Email Address>
  -subject=<Subject>
  -msg=<Filename>
  -text=<Text Message>
  -attach=<Filename>
  -log=<Filename>
  -config=<Filename>

 An example of a valid line would be:

 commail -host=mail.hsv.com -from=eric@hsv.com -to=everyone@world.com -msg=c:\windows\readme.txt

 NOTE: If the parameter contains spaces, then you will need to type quotes around it.
      example: -text="Hi, how are you doing?"

0
 

Author Comment

by:rderidder
Comment Utility
Please let me know if it queues the email.
Thanks
Rich
0
 
LVL 16

Expert Comment

by:Kyle Schroeder
Comment Utility
rderidder:
I think darrenburke's suggestion is a program that is self-contained and sends the mail directly, bypassing Outlook.  The message is submitted directly to the SMTP (Simple Mail Transport Protocol, email) server.  So you'd have to bundle the commmail.exe into your CD setup somewhere and call it at the end of the installation.  Sounds feasible at least...

-d
0
 
LVL 25

Expert Comment

by:dew_associates
Comment Utility
Makes sense dog!
0
 
LVL 4

Expert Comment

by:darrenburke
Comment Utility
if you try develop something that uses MAPI rather than just SMTP you need to make sure the clients have Outlook 2000 WITHOUT SP1 or SP2.  Security enhancements in Outlook will not allow the client to send messages automatically.  You will not have this problem using SMTP (and using COMMAIL)
0
 

Author Comment

by:rderidder
Comment Utility
I think I'm going witht he vbs.
I am in the midst of testing it on a client who is not connected.. But it works fine with a connected user.

As long as Outlook saves it, and retries sending it once the user connects, I'm happy.

RDR
0
 
LVL 10

Expert Comment

by:Longbow
Comment Utility
Ok, happy if it is working.
I will add an option.
If there is no way to send then save the message to a file.
When the connection is established then send the file as message.

How it works for you ?
Wich message do you use and how ?
What are exactly the conditions ?
0
 

Author Comment

by:rderidder
Comment Utility
Still havn't tested the queing thing.. But I'm pretty confident.
0
 
LVL 10

Expert Comment

by:Longbow
Comment Utility
Test it and create a new question about queuing the mails.
0
 
LVL 10

Expert Comment

by:Longbow
Comment Utility
Test it and create a new question about queuing the mails.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
HOW TO: Upload an ISO image to a VMware datastore for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere Host Client, and checking its MD5 checksum signature is correct.  It's a good idea to compare checksums, because many installat…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now