Solved

Email thru dos batch file with attachment... please help...

Posted on 2004-09-16
5
2,458 Views
Last Modified: 2012-05-05
good day to all,

could someone hellp me regarding my problem. Because everyday im sending an email to my boss email address using yahoo and attaching a file config.txt generated by our POS server for everday report. what i want to do is...

1. emal my boss using dos batch file....
2. attached the config.txt to the email....
   note:config.txt located at the sub-directory \control
3. should be no ms dos box arround when running(annoying)...
4. should work on any windows platform.... (for future use)...

please help me with this problem of mine. it will help me less my stress at work. not minding email at my boss everyday...

i will add a point on whom help me best.

sorry for my english. thank you..
0
Comment
Question by:dezmay
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
RanjeetRain earned 63 total points
ID: 12080743
0
 
LVL 3

Expert Comment

by:domj
ID: 12080808
Is there a reason why you need to use a batch file? A very simple VBScript will do the job for you.

Dom
0
 
LVL 3

Assisted Solution

by:domj
domj earned 62 total points
ID: 12080827
Paste this into a text file and change the extension to .vbs (After replacing the {values} with correct values). This will require no third party downloads.

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set fso=CreateObject("Scripting.FileSystemObject")

strSMTP="{EnterYourSMTPServer}"
strSubject="{EnterSubject}"
strSubject="{EnterRecipient}"
strSubject="{EnterSenderAddress}"
strBody="{EnterBodyText}"
strAttach="{EnterAttachmentPath}"

If fso.FileExists(strAttach) then
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1    ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTP
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    .Update
End With
With iMsg
    Set .Configuration = iConf
    .To = strRecipient
    .CC = ""
    .BCC = ""
    .From = "<" & strSender & ">"
    .Subject = strSubject
    .TextBody = strBody
    .AddAttachment strAttach
    .Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Else
MsgBox "The specified attachment does not exist"
End if
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Dom
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
dividesSelf challange 15 82
WPF - External data binding to controls inside a UserControl 2 44
strDist challenge 35 84
Magic Software info 18 105
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

747 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

12 Experts available now in Live!

Get 1:1 Help Now