Skip to main content
Hello.

I have an activity that has 2 destination queues as destination, each with an active directory group assigned to it. I have a default client event in this activity which sends an email to each user in the destination.
What I want to do now is change it so that only the users of ONE of the two destination queues receive an email (but the activity must still be assigned to both). Any ideas how I could do that (with code)? If I could somehow access the users of the destination queues, so that I could skip sending the email for a user who is contained only in the non-email destination queue, but I do not know how to do that.

Thank you.
You need to change the address of the e-mail. Also, you'll need to create an outlook group for the destination Q that receives the e-mail.

e.g:

Sub Main(ByVal K2 As ServerEventContext)
SMTPFunction(K2)
End sub

Function SMTPFunction(Byval K2 as ServerEventContext)
Dim objMsg As New System.Web.Mail.MailMessage()
Dim objAttachment As System.Web.Mail.MailAttachment
Dim objSender As System.Web.Mail.SmtpMail
Dim strFrom as String
Dim strEmail As String
Dim strSubject As String
Dim strBody As String

objSender.SmtpServer = K2.StringTable("MailServer")
strFrom = "Your From Address here"

strEmail = "Your destination outlook group here"

strSubject = "Subject here"
strBody = "Body here"

objMsg.To = strEmail
objMsg.From = strFrom
objMsg.Body = strBody
objMsg.Subject = strSubject
objSender.Send(objMsg)
End Function

Thanks, that's a good idea.
But this would force me to create and maintain a bunch of outlook groups in addition to my active directory groups, and I'd have to make sure the two are synchronized. Isn't there a way for me to access the contents of a destination queue from within the event? Something like that would be much simpler for me.
I had basically the same problem and I ran up against a brick wall in so far as adding a queue dynamically to the mail message was concerned. I think (it was a while back) that I discovered that K2 takes the Q apart and adds each user individually or something like that.

Due result: Outlook group is your friend 😎
There's no easy way to get to the Queue users from within the event. You can use the K2Mng object's DestQueue class' Data property to get the appropriate LDAP string for the AD Group in question. From there you can use the normal .Net DirectoryServices class to query AD directly with this LDAP string.

Hope this helps,
Ockert
Thanks. I will check how to query AD in MSDN, it shouldn't be too difficult.
If I may impose on you just a little more, could you give me some sample code on how to use the K2Mng object to get the LDAP string for a particular Destination Queue, I couldn't work it out or find it on the documentation.
Thank you very much.

Reply