My Blog List

Monday, June 27, 2011

Send Mail from Automation Scripting


Often we have scenarios to send the reports after execution of scripts via scripting. Here is an example...

Dim msg
Set msg = CreateObject("CDO.Message")
msg.From="abcd@gmail.com"
msg.To="efgh@gmail.com"
msg.Subject="Testing1 Sub"
msg.TextBody="Testing1 Body"
msg.AddAttachment("C:\\test.xls")
msg.Send
set msg=nothing
msgbox "Finished"


If you guys want to send with detailed things, 
Refer CDO.Message Object reference...

Below lines are optional. But sometimes we need to add these lines to pass....

msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=cdoAnonymous
'msg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=cdoBasic
msg.Configuration.Fields.update

Steps to create COM Exposed DLL


Open Visual Studio and Create a Project.

1. Create a CLass Library
2. Inside the .vb file, Create a Interface first.
3. Create class by inheriting from Interface.
4. Create Strong Name under "Signing" TAB of Properties.
5. Enable the "Register for Com Interop" under "compile" TAB of Properties
6. Enter the Assembly Information under "Application" TAB of Properties
7. Build the Solution.

After this,

1. Goto "Visual Studio 2010 Command Prompt"
2. Navigate to dll path
3. Register the dll using "regasm" like regasm test.dll /tlb:test.tlb

Now Registry Entries will be done under CLSID and Interface. Then

4. Export to GAC(Global Assembly Cache ie. C:\Windows\Microsoft.Net\Assembly\) using "gacutil.exe" like gacutil /i test.dll

That's all.... We can use the COM application....

Refer the links:
===============
http://www.codeproject.com/KB/COM/nettocom.aspx
http://www.15seconds.com/issue/040721.htm

Also you can do by compiling directly through command line. Refer
http://relevantcodes.com/intellisense-for-your-custom-class-in-6-steps/