Pages

30 October, 2013

.Net: Sending email with AlternateView, LinkedResources: System.Net.Mail

Recently we faced an issue in receiving mails from same (sender) domain email account but using different SMTP server. Mail body has few resources like GIF, JPEG and they are loaded with AlternateView (System.Net.Mail.MailAddress.AlternateViews) parameter with linked resources. 

Ex: sender@example.com sends mail to recevier@example.com using a different SMTP server (ex: mailserver.com) i.e. not using example.com (SMTP) domain.
Result of this scenario: Receiver did not receive any email. 

In mail body, resources can be loaded with the below options.

The mail could be blocked due to Exchange Intelligent Message Filter as in Microsoft Exchange server. Also to note that emails to other providers like GMAIL, YAHOO were successful.

When we remove all the resources in the email body, email reached the destination mail boxes but without any resources. Initially, to get the resource image, the below line was used.

LinkedResource image = new LinkedResource(imageResource) { ContentId = contentId };
view.LinkedResources.Add(image);
message.AlternateViews.Add(view);

Solution:
We did a small tweak to add proper content type for the resource which apparently resolved the issue. 

LinkedResource image = new LinkedResource(imageResource, MediaTypeNames.Image.Gif) { ContentId = contentId };
view.LinkedResources.Add(image);
message.AlternateViews.Add(view);

By this way, we are explicitly defining the content type of the resource. Of-course, we can simply disable the filter in the exchange server to receive the email but amending the resources in the mail body with proper content type has been skipped by the exchange filters. 

13 October, 2013

Smart Tools-1: Add Version and Copy Content

Recently I published a Sitecore tool (idea was old but did not get time to work on itJ) to add a version and copy the field content from the source language to the selected destination language(s).

This tool does the following tasks. 
  • It adds a new version to the selected destination language(s) version.
  • It copies the content from the source language (context item) to all selected destination language(s).
  • It has the option of including the child items as well.

Installation:

There is a package which you can download from the Sitecore marketplace. You can use Sitecore inbuilt installation wizard to install the package. The package includes an assembly, XML control and a config file.

How to use:
  • Once installed, you will have a menu item in the content tree. 


  • On selecting this menu, a window will open with all the available options. Source language is from the context language. If the source language is different from the default language, please change it and select the menu. 


  • An alert window will show you the message on the completion of the process. 


That's it

Smart Tools-2 will be published soon. ;)

Update: (1/13/2015)

  • Version 2.0 has been released in Marketplace. 
  • It supports Sitecore 7.0+ and SXP 8.
  • In SXP 8 , you  may need to disable the analytics and install the package.

Update: (7/27/2016)


  • Version 3.0 has been released in Marketplace. You can download it here. 
  • It supports Sitecore 8.1 with shared layout. 


08 October, 2013

Tools: Recycle .NET Application Pool Remotely

Recently I created an application to recycle the .net Application pool without logging into the server. It is a .net website with a dropdown showing the list of servers. On selecting a server, user can populate the all the application pools available in that server and user can recycle the application pool.


Page with dropdown and buttons.


List of application pools and a button to recycle it. 



  • The server list can be added in the configuration file.
  • Status Check will provide you the status of the application pool.
  • This .Net application should run with an account which has admin access to all the servers.
  • SMTP can be configured in the web.config.
  • After each recycle, this application will send a mail to the list of configured email ids.
  • This application logs the activity in the logs folder.


You can download the application here.


blockquote { margin: 0; } blockquote p { padding: 15px; background: #eee; border-radius: 5px; } blockquote p::before { content: '\201C'; } blockquote p::after { content: '\201D'; }