Category Archives: Exchange

Exchange 2013 manage content filter

in Exchange 2013, to bypass content filter for a domain, use this commnad:

>Set-ContentFilterConfig -BypassedSenderDomains @{Add=””}

the command to see if is correctly added:


RunspaceId : 8ac5b14d-ece0-4226-a8a7-c5bd9ebc98a9
Name : ContentFilterConfig
RejectionResponse : Message rejected as spam by Content Filtering.
OutlookEmailPostmarkValidationEnabled : True
BypassedRecipients : {}
QuarantineMailbox :
SCLRejectThreshold : 7
SCLRejectEnabled : True
SCLDeleteThreshold : 9
SCLDeleteEnabled : False
SCLQuarantineThreshold : 9
SCLQuarantineEnabled : False
BypassedSenders : {}
BypassedSenderDomains : {}
Enabled : True
ExternalMailEnabled : True
InternalMailEnabled : False
AdminDisplayName :
ExchangeVersion : 0.1 (8.0.535.0)
DistinguishedName : CN=ContentFilterConfig,CN=Message Hygiene,CN=Transport
Identity : ContentFilterConfig
Guid : 83ecbc9b-1c45-470b-ab7f-6f9a4d756130
ObjectCategory : p—-.local/Configuration/Schema/ms-Exch-Message-Hygiene-Content-Filter-Con
ObjectClass : {top, msExchAgent, msExchMessageHygieneContentFilterConfig}
WhenChanged : 13/03/2015 9:35:53
WhenCreated : 07/03/2014 13:07:04
WhenChangedUTC : 13/03/2015 8:35:53
WhenCreatedUTC : 07/03/2014 12:07:04
OrganizationId :
OriginatingServer : SERVER2K12.p—-.local
IsValid : True
ObjectState : Unchanged


Read More ...

Exchange 2010 checklist after installation

Hi Guys!

this is a list of common tasks to do after a tipical Exchange installation for an small-medium Bussiness

  • Enable Circular logging: (normaly you need to do it for prevent disk filling up)

  • Don’t forget to configure limits for mailboxes:

  • A common mistake is to not assing a offline address book on the database

  • About Hub transport, you need to create a send connector to send mail

  • especially set message limits (remember to do it in all connectors send and receive)

  • On the client connectors you need to increase message size limits, for a lot of times errors on sincronization off outlook clients is for this reason
  • I was a bad experience about this, becose outlook not sincronizes messages bigger than this limit.

  • If you want to configure the exchange server with basic authentication (SMTP) on port 25,  you have to disable the higlighted option:

  • If the exchange is a front-end server, that receives messages for a domain, you have to allow anonymous Users on the Default Receive connector

  • If you want to configure POP3 or IMAP access,

  • If you want to use basic port and basic authentication, enable the higlighted option:

  • Remember to change the Services (POP3 and IMAP4) to automatic startup.

  • For OWA and Activesync, remember to inform the external url of your server

  • After install you may be experience the error on the Outlook clients (oflline address book) the famous =”0x8004010F”, this is becose the offline address book is created on 5:00 am by default:

  • You can wait for next day or if you want to create it manualy , you can do this:

1. Run Update-OfflineAddressbook “offline address book”  in Exchange Management Shell. e.g

Update-OfflineAddressbook “Default offline address book”

2. Restart System Attendant Service on the OAB Generation Server (Mailbox Server). This service is responsible for generating the OAB by communicating with Active Directory infrastructure.

3. Either run following command in EMS

Update-FileDistributionService “CASServerName”

or just restart File Distribution Service on CAS Server.

File distribution service copies the OAB from the Mailbox Server, where System Attendant Service puts OAB in a shared folder “C:\Program Files\Microsoft\Exchange Server\ExchangeOAB”. Outlook clients then download the OAB from CAS published OAB Virtual Directori

  • Another tipical error is “Unable to relay” when clients authenticated to SMTP server from outside organization, you can do this to solve:

To enable any authenticated user to relay as any address, run the following powershell, changing the connectors name for yours:

Add-AdPermission -Identity “Default Receive Connector” -User “NT AUTHORITY\Authenticated Users” -ExtendedRights ms-Exch-SMTP-Accept-Any-Sender

more information at this link:


Read More ...

Export Exchange Audit logs

One of the most powerfull feature of Exchange logs is the possibility to audit for example all emails send from the source domain: every day and send a mail to some user, this is one sample scrit that colects information and sends a mail:

$file= "c:\prova.csv" 
$mailboxdata= Get-MessageTrackingLog -Start "10/14/2013 00:00:00"| Where-Object {$_.sender -like "*"} | Select-Object eventid,sender,timestamp,@{Name="Recipients";Expression={$_.recipients}},@{Name="RecipientStatus";Expression={$_.recipientstatus}},messagesubject $mailboxdata | export-csv "$file" 
$smtpServer = "" 
$att = new-object Net.Mail.Attachment($file) 
$msg = new-object Net.Mail.MailMessage 
$smtp = new-object Net.Mail.SmtpClient($smtpServer) 
$msg.From = "" 
$msg.Subject = "Emails Summary" 
$msg.Body = "Attached is the email server mailbox report" 

Read More ...

Export MSSQL information to Exchange public folder

This is a small example of how to collect the contact (in this case a table of Microsoft Dynamics Navision MSSQL) in a public folder Exchange contacts “test”,to do this there are several methods, in Exchange 2007 and Exchange 2010 sp1 is better to use EWS (Exchange Web sevices), but Exchange 2003 does not have that feature, alternative ways: (WEBDAV, COM, DLL from third parties, etc. .. .)
The easiest way I found is using the COM reference Microsoft Outlook 12.0 within the proposed visual studio 2008 in c #, not if it is the best and the fastest, the advantage is that it is compatible with all versions of Exchange.

	timer1.Enabled = false;
	int a,rpcCount;
	lblmis.Text = "Sincronizando Contactos...";
	Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
	NameSpace oNS = oApp.GetNamespace("MAPI");
	Registre reg = new Registre();
	MAPIFolder oAllPublicFolders; //what it says on the tin
	MAPIFolder oPublicFolders; // as above
	MAPIFolder objContacts; //as above
	//search the folder test in public folders
	oPublicFolders = oNS.Folders["Carpetas públicas"];
	oAllPublicFolders = oPublicFolders.Folders["Todas las carpetas públicas"];
	objContacts = oAllPublicFolders.Folders["test"];
	Items oItems = objContacts.Items;
	a = oItems.Count;
	progressBar1.Maximum = a;
	progressBar1.Value = 0;
	// search contacts from a table from MSSQL :
	string sql;
	SqlDataAdapter da;
	DataTable DTsql = new DataTable();
	DataSet ds;
	ds = new DataSet();
	string dsn = "server=" + servidor + ";database=" + bbdd + ";uid=" + usuari + ";pwd=" + password;
	SqlConnection myconnection = new SqlConnection(dsn);
	sql = "SELECT * FROM [" + empresa + "$Contact] ";
	da = new SqlDataAdapter(sql, myconnection);
	//delete non existents ( the primary key of the contact is "CustomerID") in my case
	lblmis.Text = "Deleting non existents..... ";
	DTsql.PrimaryKey = new DataColumn[] { DTsql.Columns["No_"] };
	progressBar1.Maximum = a;
	a = 0;
	rpcCount = 0;
	progressBar1.Value = 0;
	foreach (ContactItem coi in oItems)
		if (coi.CustomerID.ToString().Trim() != "")
			DataRow resul= DTsql.Rows.Find(coi.CustomerID.ToString());
			if (resul == null)
				lblmis.Text = "deleting: " + coi.FirstName.ToString();
		resul = null;
		// the next is necessary if you use outllook in cached mode ( to solve the error only 250 items can be open error)
		if (rpcCount > 50)
			lblmis.Text = "Borrant no existents..... ";
			rpcCount = 0;
			//force garbage collection and see if that decrements open message counter on exchange server.  We have used both a countdown loop as shown here, and also during each single loop.
			GC.WaitForPendingFinalizers();  //tried a second one also based on the articles
		lbltemps.Text = progressBar1.Value.ToString();
		progressBar1.Value = progressBar1.Value + 1;
	//update or Add existents ( the primary key of the contact is "CustomerID") in my case
	a = 0;
	rpcCount = 0;
	if (DTsql.Rows.Count > 0)
		progressBar1.Maximum = DTsql.Rows.Count;
		progressBar1.Value = 0;
		// Do for each row in the sql result
		foreach (DataRow dr in DTsql.Rows)
			lbltemps.Text = progressBar1.Value.ToString();
			lblmis.Text = dr["Name"].ToString();
			// set the first and last name to search for
			string sFirstName = dr["No_"].ToString();
			// field name to search in [] and the value to search in ''.
			string sSearch = String.Format("[CustomerID]='{0}' ", sFirstName);
			ContactItem contact = (ContactItem)oItems.Find(sSearch);
			if (contact != null)
			// Contact found, update
			if (altes.Trim() != "1")
				contact.FirstName = dr["Name"].ToString().Replace("'", "´").ToString();
				contact.LastName = "";
				contact.Email1Address = dr["E-Mail"].ToString();
				contact.MailingAddressStreet = dr["Address"].ToString().Replace("'", "´").ToString() + "\n " + dr["Address 2"].ToString().Replace("'", "´").ToString();
				contact.MailingAddressCity = dr["City"].ToString();
				contact.MailingAddressPostalCode = dr["Post Code"].ToString();
				contact.PrimaryTelephoneNumber = dr["Phone No_"].ToString();
				contact.HomeFaxNumber = dr["Fax No_"].ToString();
				contact.TelexNumber = dr["Telex No_"].ToString();
				contact.Email2Address = dr["E-Mail 2"].ToString();
				contact.MailingAddressState = dr["County"].ToString();
				contact.CompanyName = dr["Company Name"].ToString();
				//add contact
				ContactItem newContact = (ContactItem)objContacts.Items.Add(OlItemType.olContactItem);
				newContact.FirstName = dr["Name"].ToString().Replace("'", "´").ToString();
				newContact.LastName = "";
				newContact.Email1Address = dr["E-Mail"].ToString();
				newContact.MailingAddressStreet = dr["Address"].ToString().Replace("'", "´").ToString() + "\n " + dr["Address 2"].ToString().Replace("'", "´").ToString(); ;
				newContact.MailingAddressCity = dr["City"].ToString();
				newContact.MailingAddressPostalCode = dr["Post Code"].ToString();
				newContact.PrimaryTelephoneNumber = dr["Phone No_"].ToString();
				newContact.HomeFaxNumber = dr["Fax No_"].ToString();
				newContact.TelexNumber = dr["Telex No_"].ToString();
				newContact.Email2Address = dr["E-Mail 2"].ToString();
				newContact.MailingAddressState = dr["County"].ToString();
				newContact.CompanyName = dr["Company Name"].ToString().Replace("'", "´").ToString() ;
				newContact.CustomerID = dr["No_"].ToString();
				//newContact.Close(OlInspectorClose.olDiscard );
			a = a + 1;
			progressBar1.Value = a;
			//the next is necessary if you use outllook in cached mode ( to solve the error only 250 items can be open error)
			if (rpcCount > 50)
				rpcCount = 0;
				//force garbage collection and see if that decrements open message counter on exchange server.  We have used both a countdown loop as shown here, and also during each single loop.
				GC.WaitForPendingFinalizers();  //tried a second one also based on the articles
	progressBar1.Value = 0;
	segons = reg.Read("segons").ToString();
	lblmis.Text = "Esperant...";
catch (SqlException er)
	MessageBox.Show(er.Message, "SQL Error");
catch (System.Exception  er)
	MessageBox.Show(er.Message, "General Error");

Read More ...

Copy Exchange 2007 Mailboxes to pst

Many people prefer to have a copy of the exchange mailboxes in a format much easier to treat or recover, this is the end of this script, which generates the files pst exported from Microsoft Exchange mailboxes, keep in mind that it has to work in a X32 machine with

  • outlook installed ( mapi32.dll )
  • have the exchange management tools installed.
  • Powershell isntalled

This tested in an environment of Exchange 2007 (x64 server) running on a pc with windows server 2003 x32.
consists of the following, a file script.ps1

get-mailbox | export-mailbox -PSTFolderPath:'X:\Dades Exchange\psts' -Confirm:$false
in this case, we will export all the mailboxes, we can filter with get-mailbox and the paremeter filter if we want to export only some.
and the export.bat to schedule the execution:
powershell.exe -PSConsoleFile "C:\Archivos de programa\Microsoft\Exchange Server\Bin\ExShell.psc1" -Command ". 'C:\script export pst\script.ps1'"

simply call the powershell script to run,
pd: if we run it on a X64 server not work


Read More ...


Subscribe to my Newsletter

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.