serving the solutions day and night

Pages

Showing posts with label email. Show all posts
Showing posts with label email. Show all posts

Tuesday, May 13, 2014

MS Dynamics CRM - Attach SSRS Report in Email Attachments

This blog will explain to call SSRS report, convert SSRS report content to HTML and place it in the body of the email, same SSRS report will convert to PDF and attached to the email.

It contains 2 class, one is email and call EmailAttachment() function to generate email. Second class name is ReportServerCredentials, it extends IReportServerCredentials, code at the end of blog.


using System.ServiceModel.Description;
using System.Security.Principal;
using System.Net;
using Microsoft.Reporting.WebForms;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Client;


MS Dyanmics CRM - Add Notes Attachment in Email

//See the previous blog about how to create new email
GUID emailID = CreateEmail(toUsers, ccUsers, subject, body);
//Pass contactID
Guid contactID = new Guid(paramValue);

private AddNotesAttachmentinEmail(GUID emailID, GUID contactID)
{
    using (XrmServiceContext xsContext = new XrmServiceContext(CRMServiceProxy))
    {
        var qry = from anno in xsContext.AnnotationSet
              where anno.contact_Annotations.contactid == contactID
              && anno.IsDocument == true
              && anno.MimeType != null
              select new
              {
              anno.Subject,
              anno.MimeType,
              anno.FileName,
              anno.DocumentBody
              };

        foreach (var rec in qry)
        {
        ActivityMimeAttachment ama = new ActivityMimeAttachment();
        ama.Subject = rec.Subject;
        ama.ObjectId = new EntityReference("email", emailID);
        ama.ObjectTypeCode = "email";
        ama.FileName = rec.FileName;
        ama.Body = rec.DocumentBody;
        ama.MimeType = rec.MimeType;
        CRMServiceProxy.Create(ama);
        }
    }
}

MS Dynamics CRM - Create Email

List<ActivityParty> ccUsers = CCUsers(string ccEmails);
List<ActivityParty> toUsers = DNSTeamUsers();

CreateEmail(toUsers, ccUsers, subject, body);

//Create Email address, email will be in Draft format.

private Guid CreateEmail(List<ActivityParty> toUsers, List<ActivityParty> ccUsers, string subject, string body)
{
    Guid orgid, userid;
    SystemUserEntity.WhoAmIResponse(out orgid, out userid);

    ActivityParty fromUser = new ActivityParty
    {
    PartyId = new EntityReference(SystemUser.EntityLogicalName, userid)
    };

    Email email = new Email();
    email.From = new ActivityParty[] { fromUser };
  
    if (toUsers!=null)
    email.To = toUsers.ToArray();
  
    if (ccUsers!=null)
    email.Bcc = ccUsers.ToArray();
 
    email.Subject = subject;

    email.Description = body;

    //Assign regarding    
    email.RegardingObjectId = new EntityReference(contact.EntityLogicalName, contactid);
   
    //connect OrganizationServiceProxy
    Guid emailGUID = CRMServiceProxy.Create(email);
    return emailGUID;
}

Tuesday, April 15, 2014

Migrating selected entities data from UAT MS Dynamics 2011 to PROD MS Dynamics CRM 2011

Migrating selected entities data from UAT MS Dynamics 2011 to PROD MS Dynamics CRM 2011

Recently i engaged a new project to migrating data from one CRM server to another CRM server for selected entities.
Challenging work is moving email related entity data to another CRM server.
Here i going to discuss only email related entity code work.

I did this work using both CRM service and direct sql update.

1) i created 2 service, let assume one is UAT and another is PROD
public static OrganizationServiceProxy U_CRMServiceProxy
{
    get
    {
    var uri = new Uri(U_URI);

    //Authenticate using credentials of the logged in user;      
    var cntCredentials = new ClientCredentials();
    cntCredentials.Windows.ClientCredential.Domain = Domain;
    cntCredentials.Windows.ClientCredential.UserName = U_User;
    cntCredentials.Windows.ClientCredential.Password = U_Pass;
    //cntCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;

    var serviceProxy = new OrganizationServiceProxy(uri, null, cntCredentials, null);
    //serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
    serviceProxy.EnableProxyTypes();

    return serviceProxy;
    }
}

Tuesday, April 1, 2014

MS Dynamics CRM 2011 E-mail Router Configuration

1) Go to MS Dynamics CRM 2011 E-mail Router -> select MS Dynamics CRM 2011 E-mail Router Configuration Manager

2) Configure Incoming and Outgoing profile

#9628 - An error occurred while delivering the e-mail message with subject

Application Event Log

#9628 - An error occurred while delivering the e-mail message with subject "Subject Line CRMDEV:00170032" in mailbox email@yahoo.com for delivery to http://crmserver.ses.com/DNS/. System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: systemuser With Id = 03e6194a-c517-e211-b15b-0050568c5ad0 Does Not Exist (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault).

This error will be display, if any duplicate E-mail Address existed in CRM records.
If yes then delete that record and verify is the issue persist.

select * from EmailSearchBase where EMailAddress = 'email@yahoo.com'

It will list all the email assigned entities.

Take the 'ParentObjectTypeCode' id passed to the below sql.
select * from entityview where ObjectTypeCode in (1,8,10117,2020)

Now verify the record exist or not, if delete it.

for example, EmailSearchBase table record list, 8 is system user
EmailAddress    ParentObjectId                ParentObjectTypeCode
email@yahoo.com    03E6194A-C517-E211-B15B-0050568C5AD0    8

select * from systemuser where systemuserid  = '03E6194A-C517-E211-B15B-0050568C5AD0'
there is no record in system user.

so i delete the entry from EmailSearchBase table.

Everything works perfectly, all the error stops.

Friday, December 14, 2012

E-Mail Templates in Microsoft Dynamcis CRM 2011

E-Mail Templates are per-formatted email messages, can use in the different ways:
  • Insert Single or multiple templates into the email body of the messages
  • Send direct email feature by using E-mail templates to send the same message to multiple records (like 1000 contacts).
  • Reference E-mail templates in workflow processes
  • Use E-mail templates in quick campaigns and campaign activities
Dynamics CRM contains more than 20 E-mail templates, like  order, thank you letter, etc.

Organization E-Mail Templates, Click 'Settings' -> Under Business, click 'Templates' -> Click 'E-mail Templates' -> a grid will display all of the E-mail templates ans their types -> Select to view/modify a E-mail template or Create new one.


Thursday, December 13, 2012

Email Tracking in Microsoft Dynamcis CRM 2011

Dynamics CRM help you track and manage email communications with customers. Dynamics CRM can send and receive email using either CRM web client or CRM for Outlook.

Dynamics CRM supports Microsoft Exchange Server, Post Office Protocol 3(POP3) and Simple Mail Transfer Protocol (SMTP) services.

Dynamics CRM E-mail Router acts as an interface between your email system and Microsoft Dynamics CRM. Otherwise Dynamics CRM for Outlook will perform similar routing and tracking functionality on each client computer.

Automatic email tracking for both the organization and the individual users.
Configure Organization's email settings, Click 'Settings' -> under System -> Click 'Administration' -> Click 'System Settings' -> Click 'E-mail' tab.