Tuesday, December 30, 2008

Remote Shut down-Script

******Shutdown, power off or restart the machine remotely ******

Dim x, y
Set objWShell = CreateObject("WScript.Shell")
Set x =CreateObject("WScript.Shell")

'wait for 10 Sec for confirmation,if not confirm it as "Yes"

y=x.Popup("System about to shutdown in 10 seconds",10,"Answer This Question:",4 + 32)

if y=7 then


Set objCmd = objWShell.Exec("shutdown /l /a /y")
else

Set objCmd = objWShell.Exec("shutdown -s -t 01")

end if

*******Other Arguments ********





Argument detials


-s shutdown the computer

-f Forces the applications to close ,close the hung/busy application instantly without prompting you to end the application manually(end now)

-a Aborts system Shut down instantly (if confirmation is no,"shutdown /l /a /y" in above example)

-t Interval for shutdown.

-r Restarts

-l Local Machine

-m \\computer_name_or_IP_Address Remote Machine

shutdown -s -f -t 10 -m \\10 indicates seconds to wait before shutdown




Friday, December 12, 2008

Sending mails from sql server

Configure datqabase email in the server...


USE MyDB
GO
Declare @tableHTML NVARCHAR(MAX)
-- @query='select * from Employee where Id=78';
SET @tableHTML =
N '<>Employee Entry Details Report' +
N '< border="1">' +
N '<><>Id< /th><>Date< /th><>EmployeeName' +
N '<>Intime< /tr>' +
CAST ( ( SELECT td =H_Id, '',
td =convert(varchar,getdate(),106), '',
td = (H_Firstname + ' ' + rtrim(H_LAstname)),'',
td = (mydb.acsuser.getFirstInTime(H_Id,convert(varchar,getdate(),106))), ''
FROM mydb.dbo.employee where H_Manager_Id=2034
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N'< /table>' ;


EXEC msdb.dbo.sp_send_dbmail @profile_name='Pname',

mailto:recipients=,
--@query='select rtrim(H_Id),cast((H_Firstname + '' '' + rtrim(H_LAstname)) as varchar(100)) as Employeename,cast(mydb.acsuser.getFirstInTime(H_Id,convert(varchar,getdate(),106)) as varchar(20)) as FirstIntime from mydb.Employeed where H_Manager_Id=2034',
@subject='Employee Entry Timings',
@body= @tableHTML,
@body_format = 'HTML',
--Attach output inside the body
-- @attach_query_result_as_file = 0 ,
--seperator
@query_result_separator = '',
--@query_result_separator ='char(10)',
--@query_result_width =880,
@query_result_header =0,
--exclude output message
@exclude_query_output = 1,
@query_no_truncate =1;


''''''''''Usefull links for the concept''''''''''''''''''''''''''''
http://msdn.microsoft.com/en-us/library/ms190307.aspx
http://msdn.microsoft.com/en-us/library/bb510680.aspx
http://blog.sqlauthority.com/2008/08/23/sql-server-2008-configure-database-mail-send-email-from-sql-database/

Thursday, April 24, 2008

google one more add on

Hi,
Here is another interesting service from Google.
Want to know, which movie is being showed in which theater at what time?
Just enter your city name. It lists everything. Really

http://www.google.co.in/movies

Hope its helpful to you all..

Monday, March 31, 2008

Strip Single Quotes While Export To Excel

Genrally to export data form Sql server to Excel.We generally do via IMPORT/Export Wizard.
The steps we generally follow are.




-Select the Source Server and the database.









-Select Destination as Microsoft Excel-Locate the file to Export Data



-Specify Whether it is direct export from table or View or any Query



-If it is from table select the table

-Execute the package




-Complete the wizard-Export the data








After export the first character in every single cell of the excel spreadsheet is
the quotation mark ' evn thoygh this is not present in the table values.

That is how Excel ISAM driver was designed to work. It adds the apostrophe to discriminate
between text and numeric values.

The Work around for this problem is

While exporting the data instead of Selecting the destination as Microsoft Excel choose it as Flat file Destination , dont forget to check check Unicode checkbox




-Specify Whether it is direct export from table or View or any Query

-If it is from table select the table

-Configure Flat file destination
set Row delimiter as - {CR}{LF}
set Column Delimtier as - Tab {t}




-Save and Execute the Package

Export the data .

Once the data is exported sucessfully,you can see the single quotes got stripped of.



--Happy Programming
**Harika**

Wednesday, March 26, 2008

Downloading File from Web server

Hi
In my previous BLog,we have seen uploading file to the Webserver,
Let us discuss today on Download.

To Download a file the steps we need to do are
1.Create a listbox and name it as "Lstfiles"
2.Create a Button control and name it as "btndownload"

In the Code behind Page.
1.Imports System.data.IO (to do file operations)
2.Imports System.Data Namespaces
3.In the page load event bind the list of files in the folder to the Listbox.

We can bind the data using GetFiles Method of Directory Class





Here I am getting the list of files from the "UploadDocs" folder from the server




Dim i As Int16
'files is an array that stores list of files in the dirctory mentioned
Dim files() As String
'Server.MapPath("UploadDocs") get address of the folder on the server machine
files = Directory.GetFiles(Server.MapPath("UploadDocs"))
For i = 0 To files.Length - 1
files(i) = New FileInfo(files(i)).Name
Next
'Bind the array to Listbox
If Not Page.IsPostBack Then
lstfiles.DataSource = files
lstfiles.DataBind()
End If








4.In btndownload Click event stream the selected file from the listbox to Response Object.






The code behind code would be as follows..


Imports System.IO
Imports System.Data


Partial Class FileDownload
Inherits System.Web.UI.Page


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


Dim i As Int16
'files is an array that stores list of files in the dirctory mentioned
Dim files() As String
'Server.MapPath("UploadDocs") get address of the folder on the server machine
files = Directory.GetFiles(Server.MapPath("UploadDocs"))
For i = 0 To files.Length - 1
files(i) = New FileInfo(files(i)).Name
Next
'Bind the array to Listbox
If Not Page.IsPostBack Then
lstfiles.DataSource = files
lstfiles.DataBind()
End If


End Sub


Protected Sub btndownload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btndownload.Click
Dim f1 As FileInfo
Dim Selfile As String
Selfile = Server.MapPath("UploadDocs") & "\" & lstfiles.SelectedItem.Text
f1 = New FileInfo(Selfile)
'Clear the buffer,if it not cleared there is a chance of OverWriting the file and file gets Corrupted
Response.Clear()
'Add ContentDisposition and Content Length,Content type to header file
Response.AddHeader("Content-Disposition", "attachment;filename=" & lstfiles.SelectedItem.Text)
Response.AddHeader("Contetn-Length", f1.Length)
Response.ContentType = "application/octet-stream"
Response.Write(Selfile)
Response.End()
End Sub
End Class






To stream a file to a browser, you must write it to the Response object. The first step in writing a file to the Response object is to call its Clear method to remove any data currently in the buffer stream. If the Response object already contains data, when you attempt to write a file to it, you will receive a corrupt file error.



Before writing the file, use the AddHeader method of the Response object to add the name of the file being downloaded and its length to the output stream. You must also use the ContentType method to specify the content type of the file. In this example, the type is set to application/octet-stream so that the browser will treat the output stream as a binary stream and prompt the user to select a location to which to save the file. In your own application you may want to set the content type to an explicit file type, such as application/PDF or application/msword. Setting the content type to the explicit file type allows the browser to open it with the application defined to handle the specified file type on the client machine.

Now, at last, you are ready to write the file to the Response object using Response.WriteFile. When the operation is complete, call Response.End to send the file to the browser.





Any code that appears after the Response.End statement will not be executed. The Response.End statement sends all buffered data in the Response object to the client, stops the execution of the page, and raises the Application_EndRequest event

Thursday, March 13, 2008

File upload in ASP.Net




Upload File to the Server
To upload a file to the server we need to do the foolowing steps.
1. Set the form encoding type to multipart/form-data.
<

.Drag Fileupload control from toolbox to designer window
3.Add a button called Upload to upload the File
4.Create folder in the server where the uploded files to be saved.In the example "UploadDocs" is the folder where all the uploded files will be saved.

By default, the ASPNET account under which ASP.NET runs does not have permission to write files to the filesystem of the server. You will need to modify the security settings on the folder used for uploads to allow the ASPNET user to write to the folder. The steps for doing so vary somewhat for the different flavors of Windows, but the basic steps are these:Using Windows Explorer, browse to the folder where the uploaded files will be saved.Access the security settings by right-clicking on the folder, select Properties, and then select the Security tab.Add the ASPNET user and allow write access.

Create a page called fileupload.aspx.

1.Create a File upload control name it as fileupload1

2.Create upload button

3. Change enctype to enctype="multipart/form-data" in Form tag


In onclick event of upload button,write the following code

Fileupload.aspx.vb code



****Imports the Name Space ***********


Imports System.IO




Protected Sub Upload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Upload.Click
Dim serverpath As StringDim filename As String
Dim f As FileInfofilename = FileUpload1.PostedFile.FileNamef = New FileInfo(filename)
If f.Name <> "" Then
serverpath = Server.MapPath("Uploaddocs")
FileUpload1.PostedFile.SaveAs(Server.MapPath("Uploaddocs") & "\" & f.Name)
End If
End Sub





Here ends your code...

Note : By default, file uploads are limited to 4M. Any attempt to upload a file largerthat 4M will result in an error message.
You can change the maximum file size that can be uploaded bychanging the maxRequestLength attribute of the httpRuntime element in the web.config file,

Tuesday, March 11, 2008

Export Data to Excel in VB

Hi,


the folowing code helps you to create Excelsheet in Vb..

Check it out

Dim oExcel As New Excel.Application()
Dim oBooks As Excel.Workbooks, oBook As Excel.Workbook
Dim oSheets As Excel.Sheets, oSheet As Excel.Worksheet
Dim oCells As Excel.Range
Dim sFile As String, sTemplate As String
Dim dt As DataTable = _
CType(Application.Item("MyDataTable"), DataTable)

sFile = Server.MapPath(Request.ApplicationPath) & _
"\MyExcel.xls"

sTemplate = Server.MapPath(Request.ApplicationPath) & _
"\MyTemplate.xls"

oExcel.Visible = False : oExcel.DisplayAlerts = False

'Start a new workbook
oBooks = oExcel.Workbooks
oBooks.Open(Server.MapPath(Request.ApplicationPath) & _
"\MyTemplate.xls") 'Load colorful template with chart
oBook = oBooks.Item(1)
oSheets = oBook.Worksheets
oSheet = CType(oSheets.Item(1), Excel.Worksheet)
oSheet.Name = "First Sheet"
oCells = oSheet.Cells

DumpData(dt, oCells) 'Fill in the data

oSheet.SaveAs(sFile) 'Save in a temporary file
oBook.Close()

'Quit Excel and thoroughly deallocate everything
oExcel.Quit()
ReleaseComObject(oCells) : ReleaseComObject(oSheet)
ReleaseComObject(oSheets) : ReleaseComObject(oBook)
ReleaseComObject(oBooks) : ReleaseComObject(oExcel)
oExcel = Nothing : oBooks = Nothing : oBook = Nothing
oSheets = Nothing : oSheet = Nothing : oCells = Nothing
System.GC.Collect()
Response.Redirect(sFile) 'Send the user to the file


Happy Programming

Thursday, March 6, 2008

Time Zone Conversions in SQL

Hi..

While surfing net i found a beautiful article..

The followiing function convert the Time zones based on the input given.. check the functions and also a table called time zone should be created that consists of OfSet values


CREATE FUNCTION udf_Timezone_Conversion(
@Source_Timezone varchar(25),
@Destination_Timezone varchar(25),
@Source_datetime datetime,
@Display_Timezone bit = 0)
RETURNS varchar(50)AS
BEGIN
--------------------------------------------------------------------------------------------------------------- Declarations-------------------------------------------------------------------------------------------------------------
DECLARE @Source_DST bit
DECLARE @Destination_DST bit
DECLARE @converted_date datetime
DECLARE @converted_timezone varchar(50)
DECLARE @year int
DECLARE @AprilDate datetime
DECLARE @OctDate datetime
DECLARE @DST_Start datetime
DECLARE @DST_End datetime
DECLARE @GMT_Offset_Source int
DECLARE @GMT_Offset_Destination int
DECLARE @converted_datetime varchar(50)
--------------------------------------------------------------------------------------------------------------- Initializations-------------------------------------------------------------------------------------------------------------
SELECT @year = DATEPART(year, @Source_datetime)
SELECT @AprilDate = 'Apr 15 ' + CONVERT(char(4), @year)
SELECT @OctDate = 'Oct 15 ' + CONVERT(char(4), @year)
SELECT @DST_Start = DATEADD(hour, 2, (dbo.udf_FirstSundayOfTheMonth(@AprilDate)))SELECT @DST_End = DATEADD(hour, 2, (dbo.udf_LastSundayOfTheMonth(@OctDate)))SELECT @DST_End = DATEADD(second, -1, @DST_End)

SELECT @GMT_Offset_Source = GMT_Offset FROM TIMEZONE WHERE Timezone_Name = @Source_Timezone
SELECT @GMT_Offset_Destination = GMT_Offset FROM TIMEZONE WHERE Timezone_Name = @Destination_Timezone
SELECT @Source_DST = DST_bit FROM TIMEZONE WHERE Timezone_Name = @Source_TimezoneSELECT @Destination_DST = DST_bit FROM TIMEZONEWHERE Timezone_Name = @Destination_Timezone
--------------------------------------------------------------------------------------------------------------- Check for valid inputs-------------------------------------------------------------------------------------------------------------
IF @Source_Timezone NOT IN (SELECT Timezone_Name FROM TIMEZONE) OR @Destination_Timezone NOT IN (SELECT Timezone_Name FROM TIMEZONE) RETURN 'You have entered an invalid time zone.'
--------------------------------------------------------------------------------------------------------------- Source date and time are during DST and both time zones observe DST-- Convert source time zone to GMT, then convert GMT to destination time zone-- Check if destination date and time are not in DST after the conversion-------------------------------------------------------------------------------------------------------------

IF (@Source_datetime BETWEEN @DST_Start AND @DST_End) AND (@Destination_DST = 1) AND (@Source_DST = 1)
BEGIN
SELECT @converted_date = DATEADD(MINUTE, - @GMT_Offset_Source - 60, @Source_datetime)
SELECT @converted_date = DATEADD(MINUTE, @GMT_Offset_Destination + 60, @converted_date)
IF @converted_date NOT BETWEEN @DST_Start AND @DST_End
BEGIN
SELECT @converted_timezone = @Destination_Timezone
SELECT @converted_date = DATEADD(MINUTE, -60, @converted_date) END ELSE SELECT @converted_timezone = DST_Abbrv FROM TIMEZONE WHERE Timezone_Name = @Destination_TimezoneEND
--------------------------------------------------------------------------------------------------------------- Source data and time are not during DST-- Convert source time zone to GMT, then convert GMT to destination time zone-- Check if destination data and time are in DST after the conversion-- If destination date and time are in DST, check if it observes DST-------------------------------------------------------------------------------------------------------------ELSE IF
(@Source_datetime NOT BETWEEN @DST_Start AND @DST_End)
OR ((@Source_datetime BETWEEN @DST_Start AND @DST_End)
AND (@Destination_DST = 0) AND (@Source_DST = 0))

BEGIN
SELECT @converted_date = DATEADD(MINUTE, - @GMT_Offset_Source, @Source_datetime) SELECT @converted_date = DATEADD(MINUTE, @GMT_Offset_Destination, @converted_date)
IF (@converted_date BETWEEN @DST_Start AND @DST_End) AND (@Destination_DST = 1)
BEGIN
SELECT @converted_date = DATEADD(MINUTE, 60, @converted_date)
SELECT @converted_timezone = DST_Abbrv FROM TIMEZONE WHERE Timezone_Name = @Destination_Timezone
END
ELSE

SELECT @converted_timezone = @Destination_TimezoneEND
--------------------------------------------------------------------------------------------------------------- Source date and time are during DST and only source time zone observes DST-- Convert source time zone to GMT, then convert GMT to destination time zone-- Check if destination date and time are not in DST after the conversion-------------------------------------------------------------------------------------------------------------
ELSE IF (@Source_datetime BETWEEN @DST_Start AND @DST_End) AND (@Destination_DST = 0) AND (@Source_DST = 1)
BEGIN
SELECT @converted_date = DATEADD(MINUTE, - @GMT_Offset_Source - 60, @Source_datetime)
SELECT @converted_date = DATEADD(MINUTE, @GMT_Offset_Destination, @converted_date) SELECT @converted_timezone = @Destination_Timezone
END
--------------------------------------------------------------------------------------------------------------- Source date and time are during DST and only destination time zone observes DST-- Convert source time zone to GMT, then convert GMT to destination time zone-- Check if destination date and time are not in DST after the conversion-------------------------------------------------------------------------------------------------------------
ELSE IF (@Source_datetime BETWEEN @DST_Start AND @DST_End) AND (@Destination_DST = 1) AND (@Source_DST = 0)
BEGIN
SELECT @converted_date = DATEADD(MINUTE, - @GMT_Offset_Source, @Source_datetime)
SELECT @converted_date = DATEADD(MINUTE, @GMT_Offset_Destination + 60, @converted_date)
IF @converted_date NOT BETWEEN @DST_Start AND @DST_End BEGIN SELECT @converted_timezone = @Destination_Timezone
SELECT @converted_date = DATEADD(MINUTE, -60, @converted_date) END ELSE SELECT @converted_timezone = DST_Abbrv FROM TIMEZONE WHERE Timezone_Name = @Destination_Timezone
END
--------------------------------------------------------------------------------------------------------------- Format the output using style 21-------------------------------------------------------------------------------------------------------------
IF @Display_Timezone = 0 SELECT @converted_datetime = CONVERT(varchar(50), @converted_date, 21)ELSE SELECT @converted_datetime = CONVERT(varchar(50), @converted_date, 21) + '; ' + UPPER(@converted_timezone)--------------------------------------------------------------------------------------------------------------- Return the output-------------------------------------------------------------------------------------------------------------
RETURN
@converted_datetime
END


************TimeZoneTable**********************


CREATE TABLE [dbo].[TIMEZONE]
( [Timezone_Name] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL , [GMT_Offset] [float] NOT NULL ,
[DST_Abbrv] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[DST_bit] [bit] NOT NULL ) ON [PRIMARY]GOALTER TABLE [dbo].[TIMEZONE] ADD CONSTRAINT [PK_TIMEZONE] PRIMARY KEY CLUSTERED ( [Timezone_Name] ) WITH FILLFACTOR = 90 ON [PRIMARY]

GO

*******************************Time Zone Values ************************

+0200 120.0 0
+0300 180.0 0
+0400 240.0 0
+0500 300.0 0
+0530 330.0 0
+0600 360.0 0
+0700 420.0 0
+0800 480.0 0
+0930 570.0 0
+1000 600.0 0
+1100 660.0 0
+1200 720.0 0
-0300 -180.0 0
-0400 -240.0 0
-0500 -300.0 0
-1100 -660.0 0
-1200 -720.0 0
AHST -600.0 HDT 1
ALASKA -540.0 ALASKA 1
ARIZ -420.0 0
AST -240.0 ADT 1
CST -360.0 CDT 1
EST -300.0 EDT 1
GMT 0.0 0
HKT 480.0 0
HST -600.0 0
INDANA -300.0 0
IST 330 0
*****************************************************************************
CREATE FUNCTION udf_LastSundayOfTheMonth
( @Date datetime )
RETURNS datetime
AS
BEGIN
DECLARE @weekday int
DECLARE @Lastday datetime
DECLARE @number int
DECLARE @day datetime
SELECT @weekday = 0SELECT @Lastday = (DATEADD(day, -1, CAST(STR(MONTH(@Date)+1) + '/' + STR(01) + '/' + STR(YEAR(@Date)) AS DateTime)))
SELECT @number = DATEPART(day, @Lastday)WHILE @weekday <> 1BEGINSELECT @day = (CAST(STR(MONTH(@Date)) + '/' + STR(@number) + '/' + STR(YEAR(@Date)) AS DateTime))
SELECT @weekday = DATEPART(weekday, @day)
SELECT @number = @number - 1ENDRETURN @day
END
GO

**************************************************************

CREATE FUNCTION udf_FirstSundayOfTheMont
h( @Date datetime )
RETURNS datetime
AS
BEGIN
DECLARE @weekday int
DECLARE @day datetime
DECLARE @number int
SELECT @number = 1
SELECT @weekday = 0
WHILE @weekday <> 1
BEGIN
SELECT @day = (CAST(STR(MONTH(@Date)) + '/' + STR(@number) + '/' + STR(YEAR (@Date)) AS DateTime))

SELECT @weekday = DATEPART(weekday, @day)
SELECT @number = @number + 1

END
RETURN
@day


ENDGO



And Finally how to use the function



select dbo.udf_Timezone_Conversion('EST','IST',getdate(),0)


This completes the function ..

Hope this will be helpful for u all

Happppppppy Programming

Tuesday, March 4, 2008

Date Time Functions in SQL

Get Year
Select datepart(Year,getdate())
or
Select Year(getdate())


Get Month
Select datepart(Month,getdate())
or
Select Month(getdate())
Get Day

Select datepart(day,getdate())
or
Select Day(getdate())
Get Week Number
Select Datepart(Wk,getdate())
Get WeekDayName
Select DateName(dw,getdate())
(to get weeknumber DateName(Week,getdate()))
Get hours
select Datepart(hh ,getdate())
Get Minutes
Select Datepart(n ,getdate())
Get Seconds
Select Datepart(ss ,getdate())

Date Time Conversions in SQL

Hi..
Here are some of the Date time Conversion Functions in sql server

Date in MM/DD/YYYY
select convert(varchar,DateColumn,108)

108 represents the format Style of date

Style ID

Style Type

0 or 100 mon dd yyyy hh:miAM (or PM)
101 mm/dd/yy
102 yy.mm.dd
103 dd/mm/yy
104 dd.mm.yy
105 dd-mm-yy
106 dd mon yy
107 Mon dd, yy
108 hh:mm:ss
9 or 109 mon dd yyyy hh:mi:ss:mmmAM (or PM)
110 mm-dd-yy
111 yy/mm/dd
112 yymmdd
13 or 113 dd mon yyyy hh:mm:ss:mmm(24h)
114 hh:mi:ss:mmm(24h)
20 or 120 yyyy-mm-dd hh:mi:ss(24h)
21 or 121 yyyy-mm-dd hh:mi:ss.mmm(24h)
126 yyyy-mm-dd Thh:mm:ss.mmm(no spaces)
130 dd mon yyyy hh:mi:ss:mmmAM
131 dd/mm/yy hh:mi:ss:mmmAM

Thursday, February 28, 2008

VB String Functons

Function Description
InStr
Returns the position of the first occurrence of one string within another. The search begins at the first character of the string

InStrRev Returns the position of the first occurrence of one string within another. The search begins at the last character of the string

LCase Converts a specified string to lowercase

Left Returns a specified number of characters from the left side of a string

Len Returns the number of characters in a string

LTrim Removes spaces on the left side of a string

RTrim Removes spaces on the right side of a string
Trim Removes spaces on both the left and the right side of a string

Mid Returns a specified number of characters from a string Replace Replaces a specified part of a string with another string a specified number of times Right Returns a specified number of characters from the right side of a string
txt="This is a beautiful day!"

document.write(Right(txt,11))Output:utiful day!

Space Returns a string that consists of a specified number of spaces StrComp Compares two strings and returns a value that represents the result of the comparison String Returns a string that contains a repeating character of a specified length StrReverse Reverses a string UCase Converts a specified string to uppercase

Vexed with "Stack overflow at line: 0" Error

Hi ,

Stack overflow at line: 0 Error really troubing me lot form several days..
I am unable to debug it..even..
I dont know how but when i removed Smartnavigation=true from my web config file it started working..

Dont ask me the reasons why??but it worked.

Monday, February 18, 2008

Sending EMails using CDO's

CDO 's are command data objects used to send Emails from SMTP server.
Before using this objects ,we need to configure the SMTP server .
Using CDO objects
Simple EMail
Set myMail=CreateObject("CDO.Message") myMail.Subject=ReportName myMail.From="HarikaWorks" myMail.To="harika.04@Gmail.com" mymail.cc="OtherReceipints@abc.com" myMail.Bcc= "OtherReceipints1@abc.com" myMail.Replyto="admin@abc.com" mymail.send()



Email with attachments
Set myMail=CreateObject("CDO.Message") myMail.Subject=ReportName myMail.From="HarikaWorks" myMail.To="harika.04@Gmail.com" mymail.cc="OtherReceipints@abc.com" myMail.Bcc= "OtherReceipints1@abc.com" myMail.Replyto="admin@abc.com" myMail.AddAttachment "D://Images/image1.gif" mymail.send()


Zip attachments in Email
Set myMail=CreateObject("CDO.Message") myMail.Subject=ReportName myMail.From="HarikaWorks" myMail.To="harika.04@Gmail.com" mymail.cc="OtherReceipints@abc.com" myMail.Bcc= "OtherReceipints1@abc.com" myMail.Replyto="admin@abc.com"
Scurdir=oFs.GetAbsolutePathName("") strcommand="winzip32.exe" Set objShell=CreateObject("WScript.Shell") strpath= "D:\\images\charts\Reports.zip" strdestination= ScurDir & "\" & sFullFileName
strcommand= strcommand & " " & " -a" & " " & strpath & " " & strdestination objShell.Run strCommand, 0, True 'wait! myMail.AddAttachment "D://Images/image1.gif" mymail.send()