Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Send Email using an email Template -- Sender should be a queue

$
0
0

Hi,

Problem - I need to send an email with following details ->

  1. Sender = A queue (i have the GUID)
  2. To = a List of "systemUsers" (i have the list)
  3. template = I have template GUID

I cant find the code or any example for this. 

Can someone help?

Here is the current code which i am using ( i am using a "systemUser" as Sender here, i need to use queue) -->

Public Sub SendEmailUsingTemplate(ByVal templateId As Guid, ByVal fromUser As Guid, _
ByVal toUsers As System.Collections.Generic.List(Of System.Guid?)) _
Implements ICrmRepository.SendEmailUsingTemplate

Dim toParties As List(Of Entity) = New List(Of Entity)
For Each id In toUsers
Dim toParty = New Entity("activityparty")
toParty("partyid") = New EntityReference("systemuser", id.Value)
toParties.Add(toParty)
Next

Dim fromParty = New Entity("activityparty")
fromParty("partyid") = New EntityReference("systemuser", fromUser)
'Changed
Dim newEmail = New Entity("email")
newEmail("to") = toParties.ToArray
newEmail("from") = fromParty
'Dim targetEmail As TargetSendFromTemplateEmail = New TargetSendFromTemplateEmail()
'targetEmail.Email = newEmail

Dim templateRequest As SendEmailFromTemplateRequest = New SendEmailFromTemplateRequest
templateRequest.Target = newEmail
templateRequest.TemplateId = templateId
templateRequest.RegardingType = "systemuser"
templateRequest.RegardingId = fromUser

_crmDataContextProvider.GetCrmService().Execute(templateRequest)

End Sub

VB.net or C# ( both languages are welcomed)

Regards

Sagar


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>