Yelena - Friday, June 26, 2009 1:47 PM:
I would like to trigger an email message when the field value is changed. Does anybody have an example?
Thanks
SamsAn - Friday, June 26, 2009 3:26 PM:
The rough design is below.
1. Add server-side method to send email:
2. Client code (called in OnChange field event for example).
Original Mind Any Level Innovator Solutions Free-Lancer, http://sites.google.com/site/caraacc
tbischel - Tuesday, February 9, 2010 5:41 PM:
So a couple of related questions:
1) When using the IOM.Item.email method to send a message, can the item be any arbitrary item, or does it have to be tied to a specific type of item to send?
2) If we don't have the mail server set up, can we still receive email notifications in the internal Aras Inbox?
3) I've read that if the sending user doesn't have an email address, this action will fail. Are there any other preconditions to either the To-Identity or the From-User? Or preconditions for the subject/body properties?
Thanks
rootkiter - Thursday, December 2, 2010 3:40 AM:
I have wrote a simple code like that:
Item fromUser = Inno.newItem("User", "get");
fromUser.setProperty("id", "30B991F927274FA3829655F50C99472E"); // ID of admin that have email address
fromUser = fromUser.apply();
Item idnt = Inno.newItem("Identity", "get");
idnt.setProperty("id", "50CCA6C2E975402EA252CCE6A87EFD2D"); // ID of Identity that have email address
idnt = idnt.apply();
string subject = "Part promotion notification";
string body = "Body body body";
// 50CCA6C2E975402EA252CCE6A87EFD2D identity daica
// 30B991F927274FA3829655F50C99472E user admin
// In this particular example instead of getting a ready template
// email from the server a new item of type “EMail Message” is created
Item email_msg = Inno.newItem("Email Message");
email_msg.setProperty("subject", subject);
email_msg.setProperty("body_plain", body);
email_msg.setPropertyItem("from_user", fromUser);
MessageBox.Show(fromUser.getID().ToString());
/// Run here OK
// Begin error
if (!fromUser.email(email_msg, idnt))
{
MessageBox.Show("Error: " + fromUser.getErrorDetail());
}
When run code, it show error, Plz help me
Brian - Thursday, December 2, 2010 7:13 AM:
It might help if you posted the error.
I tried a similar test to this recently. I retrieved a "default" email item from the server and then sent it after replacing the body and subject. It worked as expected. This gets around not correctly creating the email message item. (which I suspect is your problem here).
So instead of
Item email_msg = inno.newItem("Email Message");
try
Item email_msg = inno.newItem("Email Message", "get");
emailMsg.setProperty("name","default email");
emailMsg = emailMsg.apply();
then set the subject, body etc and send.
Cheers,
Hope this helps,
Brian.
rootkiter - Thursday, December 2, 2010 8:53 PM:
Thank for your quickly answer, i have try your way and it run without error.
But the identity haven't receive email not yet.
The identity created like that:
- Create user have first name 'dai' and last name 'ca' and email '[email protected]'
- Enable daica login to system
=> we have Identity 'dai ca'
But when i try to send default email 'CM Activity Notification' to 'daica' from user that have email '[email protected]',
nothing happen.
Brian - Friday, December 3, 2010 5:58 AM:
Can you send an email through a normal Workflow Notification?
You may not have your email server set up properly.
If you can send email through a workflow notification then maybe the identity receiving the email is not correctly formed.
This is the test code I used the other day that works.
Item emailMsg = this.newItem("EMail Message", "get");
emailMsg.setProperty("name", "defaultEmail");
emailMsg = emailMsg.apply();
emailMsg.setProperty("subject","New method sent email");
emailMsg.setProperty("body_plain","new body text " + action);
Item subs = this.newItem("Identity", "get");
subs.setID( subscriptions.getProperty("subscriber")); // where subscriber is an Identity ID
subs = subs.apply();
bool res = email(emailMsg, subs);
I also have the "InnovatorServerConfig.xml" file email debug parameter set so that emails are created as text files on the server. That way the email server does not have to be working in order to test if emails are being created.
<operating_parameter key="email_debug_option" value="file"></operating_parameter>
Emails are created in the "Temp" folder where Innovator is installed. ....Innovator/server/temp
Cheers,
Brian.
dlpoore62 - Wednesday, June 22, 2016 2:13 PM:
Brian,
I have an e-mail message item that I would like to use to notify the created_by_id that a field on the form has been entered on a specific custom item. From a simple logic perspective, I would like to utilize a field event (on-change) that essentially:
- sends e-mail message "Tracking Number Available" - id=42E4609710524574A82062F83B8102B4
- to created_by_id (item type "user" - id=CF27A74D871E4DA8B7F656E2F8240FEE)
- for item Sample_Request (id = ACBC20597D364DCFA035A43CBDC41B43 )
There are fields within the e-mail message that will be populated based on the specific item.
Any thoughts?
Darryl
Brian - Wednesday, June 22, 2016 9:38 PM:
Daryl,
I think the suggestion above is still the right one.
Create a server method to actually send the email.
Call the server method from the client on the "onChange" trigger.
Things to look out for here. The item will need to be saved already so that you have access to everything on the server side OR you will have to pass in all of the data that is only in the client form.
I think in this situation it is easier to hand craft an email rather than use the in build email message.
Send an email from Innovator using the System.Net.Mail objects
// Generic method.
// expecting
// <subject>subject</subject>
// <body>body text - could be html</body>
// <from>email address of who to send from = User if send from Logged On User</from>
// <to>list of email addresses, comma separated</to>
// <attachments>list of files, comma separated fully qualified file names</attachments>
Innovator inn = this.getInnovator();
Item smtpVar = this.newItem("Variable","get");
smtpVar.setProperty("name","smtp server");
smtpVar.setAttribute("select","value");
smtpVar = smtpVar.apply();
string smtpSrv = smtpVar.getProperty("value","");
if ( smtpSrv == "" ){
return inn.newError("No SMTP Server set for emails with attachements. See 'smtp server' Variable under Administration.");
}
string subject = this.getProperty("subject","");
string body = this.getProperty("body","");
string from = this.getProperty("from","user");
string toList = this.getProperty("to","");
string attachmentsList = this.getProperty("attachments","");
//string[] to = toList.Split(new char[] {','});
string[] attachments = attachmentsList.Split(new char[] {','});
//System.Diagnostics.Debugger.Break();
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
Item usr = this.newItem("User","get");
usr.setID(inn.getUserID());
usr.setAttribute("select","email");
usr = usr.apply();
if ( usr.isEmpty() ){
return inn.newError("Unable to retrieve logged on user credentials: " + usr.getErrorDetail());
}
System.Net.Mail.MailAddress fromAdr = new System.Net.Mail.MailAddress(from);
message.From = fromAdr;
message.To.Add(toList);
message.Subject = subject;
message.Body = body;
message.IsBodyHtml = true;
for ( int i = 0; i < attachments.Length; i++){
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(attachments[i]);
System.Net.Mime.ContentDisposition disp = attachment.ContentDisposition;
disp.CreationDate = System.IO.File.GetCreationTime(attachments[i]);
disp.ModificationDate = System.IO.File.GetLastWriteTime(attachments[i]);
disp.ReadDate = System.IO.File.GetLastAccessTime(attachments[i]);
message.Attachments.Add(attachment);
}
//System.Diagnostics.Debugger.Break();
try{
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient(smtpSrv);
//try{
client.Send(message);
} catch (Exception e){
message.Attachments.Dispose();
return inn.newError("Exception : " + e.Message);
}
message.Attachments.Dispose();
return this;
Hope this helps,
Brian.