我創建了一個插件(使用開發人員工具包),該插件將發送郵件到Participants
,該郵件在創建Participants
時轉換爲Contacts
。 但是這個插件不工作。當我試圖調試它時,下面的消息出現在插件註冊工具(SDK)中爲什麼發送電子郵件插件不工作?
Profiler> Plug-in AppDomain Created
Profiler> Parsed Profiler File Successfully.
Profiler> Constructor Execution Started: XXXXXXXX
Profiler> Constructor Execution Completed Successfully (Duration = 8ms).
Profiler> Profiler Execution Started: XXXXXXXXXXX
Plug-in> Entered CRMEmailToParticipantsPackage.EmailPlugins.PostParticipantCreate.Execute(),
Plug-in> Exiting CRMEmailToParticipantsPackage.EmailPlugins.PostParticipantCreate.Execute(),
Profiler> Profiler Execution Completed Successfully (Duration = 57ms).
Profiler> Profiler AppDomain Unloaded
。管道階段是對創建消息進行預驗證。 這是我的代碼:
protected void ExecutePostParticipantCreate(LocalPluginContext localContext)
{
if (localContext == null)
{
throw new ArgumentNullException("localContext");
}
// TODO: Implement your custom Plug-in business logic.
IPluginExecutionContext context = localContext.PluginExecutionContext;
IOrganizationService service = localContext.OrganizationService;
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
try
{
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName == "new_participant")
{
Guid Contact_id = ((EntityReference)entity.Attributes["new_participantscontact"]).Id;
Guid trip_Id = ((EntityReference)entity.Attributes["new_tripparticipants"]).Id;
ColumnSet col1 = new ColumnSet("new_name", "new_date", "new_destination");
Entity trip = service.Retrieve("new_trip", trip_Id, col1);
var Trip_name = trip.Attributes["new_name"];
var Trip_date = trip.Attributes["new_date"];
var Trip_destination = trip.Attributes["new_destination"];
string emailBody = "Hi, your " + Trip_name.ToString() + "is booked on : " + Trip_date.ToString() + "; Destination : " + Trip_destination.ToString();
Guid _userId = context.UserId;
ActivityParty fromParty = new ActivityParty
{
PartyId = new EntityReference(SystemUser.EntityLogicalName, _userId)
};
ActivityParty toParty = new ActivityParty
{
PartyId = new EntityReference("new_participantscontact", Contact_id)
};
Email email = new Email
{
To = new ActivityParty[] { toParty },
From = new ActivityParty[] { fromParty },
Subject =Trip_name.ToString()+ " :Trip Details",
Description = emailBody,
DirectionCode = true
};
Guid emailID = service.Create(email);
SendEmailRequest req = new SendEmailRequest();
req.EmailId = emailID;
req.TrackingToken = "";
req.IssueSend = true;
SendEmailResponse res = (SendEmailResponse)service.Execute(req);
}
}
catch (FaultException ex)
{
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}
}
}
我有沒有做過任何事情錯在這裏?
謝謝。
你怎麼知道插件沒有燒製? – 2013-03-14 09:28:00
Sry它的解僱,我正在使用SDK pluginregistration工具分析這個插件,同時調試什麼都沒有發生 – 2013-03-14 09:40:44