Hi!
I've read the code on https://msdn.microsoft.com/en-us/library/hh547397.aspx but not happy with my solution.
I manually create a DistributeCampaignActivityRequest in a consoleApplication
Here are some codesnippets (sender is a systemuser or a queue)
Entity emptyMail = new Entity("email");
emptyMail.Attributes["from"] = new Entity("activityparty") { Attributes = new AttributeCollection { {"partyid", sender } } };
activityRequest = new DistributeCampaignActivityRequest {
Activity = emptyMail,
TemplateId = emailTemplateId,
CampaignActivityId = campaignActivity.Id,
Owner = new EntityReference("systemuser", currentUser.UserId),
//OwnershipOptions = PropagationOwnershipOptions.Caller,
PostWorkflowEvent = true,
Propagate = true,
SendEmail = true,
};
var distributeResponse = (DistributeCampaignActivityResponse)_client.Execute(activityRequest);
The email will be created and sent, but.... the sender is the user of the connectionString and not the one set as Attribute "from" in the email-Entity.
I've tried a lot of things but no chance. If I set the callerId of the serviceProxy:
_client.OrganizationServiceProxy.CallerId = sender.id
It's o.k. but this is only possible if the sender is a systemuser.
What else I've tried:
- set owner of the request to sender (systemuser or queue)
- set the from of e-mail in this way:
emptyMail.Attributes.Add("from", new EntityCollection());
(emptyMail.Attributes["from"] as EntityCollection).Entities.Add(new Entity("activityparty"));
((emptyMail["from"] as EntityCollection)[0] as Entity).Attributes.Add("partyid", sender);
Anybody has a solution for this?
thx a lot
©a-x-i







