Send bulk email using gmail or any other server


1. Visit  and enable access for less secure apps for some time

2. Verify that your machine where powershell is available , latest version of .Net Framework is installed.

3.  Verify that in powershell you have “Send-MailMessage” available .

(in powershell window type  :—- Get-Command Send-MailMessage )

4.   Export your gmail/ any other email account contacts as csv  . Say it has name of contact column as “name”  and email as “email”

5. Create the sample html you want to send , say

6. Here is a sample ps1 using  “Send-MailMessage” with gmail

7. Give your sleep time in powershell script  with respect to  Gmail send message limits  and

8. don’t forget to disable less secure apps @   after you are done .





null id in entry (don’t flush the Session after an exception occurs)

Sample Exception :  ( This example is using postgresql 9.3)

null id in YourModelNamespace.Model entry (don’t flush the Session after an exception occurs)
NHibernate.AssertionFailure was caught
Message=null id in YourModelNamespace.Model  entry (don’t flush the Session after an exception occurs)
at NHibernate.Event.Default.DefaultFlushEntityEventListener.CheckId(Object obj, IEntityPersister persister, Object id, EntityMode entityMode)
at NHibernate.Event.Default.DefaultFlushEntityEventListener.GetValues(Object entity, EntityEntry entry, EntityMode entityMode, Boolean mightBeDirty, ISessionImplementor session)
at NHibernate.Event.Default.DefaultFlushEntityEventListener.OnFlushEntity(FlushEntityEvent event)
at NHibernate.Event.Default.AbstractFlushingEventListener.FlushEntities(FlushEvent event)
at NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent event)
at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)
at NHibernate.Impl.SessionImpl.Flush()
at NHibernate.Transaction.AdoTransaction.Commit()
at YourNamespace.UnitOfWork.NHibernateUnitOfWork.Dispose(Boolean disposing) in c:\Users\……….\UnitOfWork\NHibernateUnitOfWork.cs:line 78
at YourNamespace.UnitOfWork.NHibernateUnitOfWork.Dispose() in c:\Users\…………..\UnitOfWork\NHibernateUnitOfWork.cs:line 36
at sourcenamespace.class.method(input parameters ) in c:\Users\hemant\…….\mycalss.cs:line 82
at wrapper.cs in c:\Users\hemant\…..\api\someController.cs:line 134


Possible Reasons / Solutions : 

1.  uninstall  FluentNHibernate  ,  NHibernate ,  Iesi.Collections . install FluentNHibernate   , it will automatically install correct version of NHibernate and Iesi.Collections required . Check if your app.config / web.config have wrong versions of dll’s referred , may be under runtime .

2. Generally  in nhiberante mappings you define id field for the table like :

Id(x => x.somecolumn).GeneratedBy.Assigned().Not.Nullable();   // reflection to determine column name so its ok to skip .column here


Id(x => x.SomeColumn).GeneratedBy.Assigned().Column(“\”SomeColumn\””).Not.Nullable();

//In the above two cases , your own code is responsible to maintain unique id . So used //Assigned


Id(x => x.SomeColumn).GeneratedBy.Assigned().Column(“some_column”).Not.Nullable();

//snake_case  so ok to skip  \”


Id(x => x.Id).GeneratedBy.Sequence(“\”My_Id_seq\””).Column(“\”Id\””);

// in the above case you have a Sequence to generate unique ids / primary key  in db

or else

The idea is after GeneratedBy  make sure you have chosen right option as per your table  e.g.

  • Assigned :   lets the application to assign an identifier to the object before Save()  is called. ( with or without Params configuration )
  • Foreign  :  uses the identifier of another associated object. Usually used in conjunction  with a one-to-one primary key association.
  • HiLo :   uses a hi/lo algorithm to efficiently generate identifiers of any integral type, given a table and column (by default hibernate_unique_key and next_hi respectively) as a source of hi values. The hi/lo algorithm generates identifiers that are unique only for a particular database. Do not use this generator with a user-supplied connection. requires a “special” database table to hold the next available “hi” value
  • Identity  :   supports identity columns in DB2, MySQL, MS SQL Server and Sybase. The identifier returned by the database is converted to the property type using Convert.ChangeType. Any integral property type is thus supported.
  • Increment :   generates identifiers of any integral type that are unique only when no other process is inserting data into the same table. Do not use in a cluster.
  • Sequence :  uses a sequence in DB2, PostgreSQL, Oracle or a generator in Firebird. The identifier returned by the database is converted to the property type using Convert.ChangeType. Any integral property type is thus supported.

See FluentNHibernate.Mapping.IdentityGenerationStrategyBuilder  for more possible options.







An error occurred. Detailed message: An error was raised by libgit2. Category = Net (Error). Response status code does not indicate success: 401 (Unauthorized).

An error occurred. Detailed message: An error was raised by libgit2. Category = Net (Error).
Response status code does not indicate success: 401 (Unauthorized).

This is what happened when I changed my password for Git Repository ( with Visual Studio Tools for Git )

Solution :

  1. Close all Visual Studio instances
  2. Go to Control Panel > Credential Manager
  3. Delete the entries related to your repository.(Link )
  4. Now whenever you will try to connect to server using Visual studio , it will ask for credentials and recreate these entries in Credential manager.

Should I Pay money to Google Adsense ? Prove using Powershell

Last week I  finalized a new hosting plan . It offers me $100 worth of code for Google adsense and similar programs.  This was the 1st time I saw Google adsense with angle of an advertiser . (Probably when I last time renewed my hosting  also , I got these codes , but never used it . Was not even aware of what it is at that moment )

1st question which comes to me , do they make us fool !!! Does this $ 100 really worth something .  After all brainstorming  my conclusion is : if you are selling a product , invest only in a program  which charges you as per actual product sale .  Never invest in Google adsense and similar programs , who just take responsibility of taking user to your door on web , if they don’t promise / convert in to actual sale , don’t pay them .

Well, I am not saying something in air . I have valid points to prove it , if you agree with below mentioned , you must admit what I said above :
Continue reading

How to Post on all of your FaceBook Groups Using Powershell ?

Powershell script saved as text here  ( Auth codes removed)


#1. This PowerShell script demonstrate how to use Facebook API's in PowerShell .
#2. How to load new framework dll . (Details ) 
#3. How to generate Auth Access Token in facebook. (Details )
#4. How to read online xml file which may be site map . ( $onlineXMLSitemap = "" ;$doc = New-Object System.Xml.XmlDocument;$doc.Load($onlineXMLSitemap);
#5. How to run c# code from powershell directly . (Add-Type -ReferencedAssemblies $mAs -TypeDefinition $cSource -Language CSharp )
#6. How to solve overload function problem in Powershell ( Post method of facebook API has two overloads , one with Path , one without path . We are using 1st . That is why we called c# code from Powershell)
#7. How to select random entries in a collection . ($doc.urlset.url | Get-Random -count 1 | ForEach-Object )
#8. Business purpose resolved : Randomly post on Facebook in my all groups . This script picks one random url from provided Sitemap.XML and post it on 100 FB Groups and your own wall . You can reduce this number though .$  | Get-Random -count 100| ForEach-Object {
#Related terms : Bulk Post on facebook , Post on All Groups ,  Use Facebook API is Powershell , Use Facebook API is c#

Continue reading