Destination Rule | Send one Email

  • 8 December 2006
  • 5 replies
  • 3 views

Badge +1
Hi Ockert, Hi Conradk2,

thanks for your great help. Now it works :D

Regards

Jessica

5 replies

Badge +1
Hello,

I'm a K2.net beginner and I have the following question. I have create a default activity and I defined three users from the Active Directory as my destination users.
Further I have acitvated the SMTP Notification because the three users should get an email with a link to the right webpage (I work with K2 SmartForms).

Now I have the problem that the three users always get three emails with different links. I think one link for every user. So they always have to look which is the right link for them. Is there the opportunity to send them one Email with the right link? Should I have to work with Destination Queues?

Regards

Jessica
Badge +11
Hi Jessica,

You're on the right track...
Did you change any of the code behind the Client Event?
Can you post the code behind the Client Event?

Regards,
Ockert
Badge +1
Hello Ockert,

I haven't changed the code behind the Client Event. Here it is:

public void Main(ClientEventContext K2)
{
try
{
SMTPFunction(K2);
}
catch (System.Exception ex)
{
throw new System.Exception(ex.Message);
}
try
{
HTTPFunction(K2);
}
catch (System.Exception ex)
{
throw new System.Exception(ex.Message);
}
}
public void SMTPFunction(ClientEventContext K2)
{
System.Web.Mail.MailMessage objMsg = new System.Web.Mail.MailMessage();
System.Web.Mail.MailAttachment objAttachment;
object strFrom = "";
object strEmail = "";
object strSubject = "";
object strBody = "";
System.Web.Mail.SmtpMail.SmtpServer = SourceCode.K2Utilities.GeneralMod.GetDefaultSMTPServer();
strFrom = K2.ProcessInstance.Originator.Email;
strEmail = "visitenkarten-cds@autovision-gmbh.com";
if((strEmail==null)||(strEmail.ToString().Trim().Length == 0))
{
throw new System.Exception("No Email Address was supplied, please rectify and try again.");
}
strSubject = "Visitenkartenbestellung von " + K2.ProcessInstance.DataFields["vorname"].Value + " " + K2.ProcessInstance.DataFields["nachname"].Value;
strBody = "Für die Bestellung von " + K2.ProcessInstance.DataFields["vorname"].Value + " " + K2.ProcessInstance.DataFields["nachname"].Value + " über " + K2.ProcessInstance.DataFields["anzahl"].Value + " Visitenkarten auf Kostenstelle " + K2.ProcessInstance.DataFields["kostenstelle"].Value + " wird Ihre Freigabe benötigt." + System.Environment.NewLine + "" + System.Environment.NewLine + "Klicken Sie auf den folgenden Link, um das Formular zur zweiten inhaltlichen Überprüfung aufzurufen:";


object strURL = "";
strURL = "http://auviwos00m07/visitenkarten/OrgaFreigabe.aspx?sn={SERIALNO}";
strURL = strURL.ToString().Replace("{SERIALNO}",K2.SerialNumber);
if(strBody.ToString().IndexOf("[Web Page URL]")>0)
{
strBody = strBody.ToString().Replace("[Web Page URL]", System.Web.HttpUtility.UrlPathEncode(strURL.ToString()));
}
else
{
strBody += System.Environment.NewLine + System.Environment.NewLine + "HTTP URL: " + System.Web.HttpUtility.UrlPathEncode(strURL.ToString());
}
objMsg.From = strFrom.ToString();
objMsg.To = strEmail.ToString();
objMsg.Subject = strSubject.ToString();
objMsg.Body = strBody.ToString();
System.Web.Mail.SmtpMail.Send(objMsg);
}

public void HTTPFunction(ClientEventContext K2)
{

string strURL = "";
strURL = "http://auviwos00m07/visitenkarten/OrgaFreigabe.aspx?sn={SERIALNO}";
strURL = strURL.Replace("{SERIALNO}",K2.SerialNumber);
K2.AddWorklist("ASP",System.Web.HttpUtility.UrlPathEncode(strURL));
}
Badge +11
Hi Jessica,

Change the line:
strEmail = "visitenkarten-cds@autovision-gmbh.com"; 

With:
SourceCode.KO.User oUser;
oUser = K2.ActivityInstanceDestination.User;
strEmail = oUser.Email;

and test again.

HTH,
Ockert
Badge +6
Hi Jesica,

When you create a destination rule and set 'Create a slot for each destination' the users will get different links.

If you select to create only one slot the link in the email should be the same.

Regards,
Conrad

Reply