Converting eml file to pdf

Hi, one of requirement for my automation task is to read eml file and save as pdf file and this has to be done in batch for several file. This is just hack how to do automate that task. THIS WILL NOT STORE THE ATTACHMENTS. Its just inserting the eml file into doc and converting it to pdf. This code is vbscript code.

wdStory=6
wdMove=0
wdNotSaveWord=0
wdSavePDF=17
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()
Set objheaderfooter = objDoc.Sections(1)

objheaderfooter.Headers(1).Range.Font.Italic = True
objheaderfooter.Headers(1).Range.Font.Color = RGB(0,0,255)

objheaderfooter.Footers(1).PageNumbers.Add
objheaderfooter.Borders.Enable = true
Set objSelection = objWord.Selection
objWord.Visible = false

objSelection.EndKey wdStory, wdMove
objSelection.TypeParagraph()

rem insert file code
objSelection.InsertFile("YOUR FILE PATH")
objSelection.EndKey wdStory, wdMove

'Save word to temp folders
timemills = now()
strfilename=replace(timemills,"/","_")
strfilename=replace(strfilename,":","_")
strfilename=replace(strfilename," ","_")
tsname="Sample"
pdfpath=tsname&"_"&strfilename&".pdf"


Set fso = CreateObject("Scripting.FileSystemObject")
foldername = now()
folderdate = split(foldername," ")
current = Replace (folderdate (0),"/","_")

rem folder path to save file
folderpath ="FOLDER PATH TO SAVE FILE"

If fso.folderexists (folderpath) then
msgbox "Folder exists not creating new one"

End if

pdfpath=folderpath&"\"&pdfpath
msgbox pdfpath
objDoc.SaveAs pdfpath,wdSavePDF
objWord.Quit wdNotSaveWord

Taking screen capture of Automation Element – TestStak.White

Hi There might be need where we want to take screenshot of particular automation element instead of the entire desktop or entire app.

Here is one way, that we can do that. I hare written general routine for getting the screen capture of the automation element.

public static void takeScreenShot(TestStack.White.UIItems.UIItem b)
 {
try
 {
 String path;
 Rect bounds = b.Bounds;

//getting values from Rect
 double h = bounds.Height;
 double w = bounds.Width;
 double x = bounds.X;
 double y = bounds.Y;

 //gettomg ramdom number, can change it to date time or somehting meaningful
 Random rndm = new Random();
 //this will generate randomnumber between 1 to 10,000
 int random = rndm.Next(10000);

//getting current directory
 path = System.AppDomain.CurrentDomain.BaseDirectory;
 //replaceing the bin and debug as BaseDirectory will return this
 path = path.Replace("\\bin\\Debug","");
 //creating path with random integer
 path = path + "results\\Screenshot_" + random + ".jpg";

//logic for creating
 //creating equalent in System.Drawing
 //Source point
 System.Drawing.Point p = new System.Drawing.Point(Convert.ToInt32(x), Convert.ToInt32(y));
 //Destination point
 System.Drawing.Point p2 = new System.Drawing.Point(0, 0);

//Creating Rectangle from Rect
 System.Drawing.Rectangle rect = new Rectangle(p.X, p.Y, Convert.ToInt32(w), Convert.ToInt32(h));

//Creating bitmap with desired height and width
 Bitmap bitmap = new Bitmap(rect.Width, rect.Height);

{
 Graphics g = Graphics.FromImage(bitmap);
 {
 //Coping screen where automation element is present (p) to destnation point on the image (0,0)
 g.CopyFromScreen(p, p2, rect.Size);
 }
 //Saving image
 bitmap.Save(path, ImageFormat.Jpeg);
 }
 }
 catch (Exception e)

{
 Console.WriteLine(e.Message);
 }

}
 }
}