FileNet P8 Content Engine, Version 4.0.+              

Handler zum Senden von E-Mail

Dieser Handler sendet eine E-Mail, wenn ein neues Dokument erstellt wurde.

Handler zum Senden von E-Mail
Content Engine 3.5.x VBScript-Version
Public Sub OnEvent (EventObject, Subscription) 
Dim myMail, MessageBody 
Set myMail = CreateObject("CDONTS.NewMail") 
myMail.From = "userl@company.com" 
myMail.To = "sysAdmin@company.com" 
myMail.Subject = "Event Notification--New Document created" 
MessageBody = "A document titled """ & Source.DocumentTitle & """ was 
Created at " & time & " on " & date & "." 
MessageBody = MessageBody + vbCrLf + Subscription.UserString 
myMail.Body = MessageBody 
myMail.Send 
Set myMail = Nothing 
End Sub 
Content Engine 4.x Java-Version
import java.util.Date; 
import java.util.Properties; 

import javax.mail.Message; 
import javax.mail.MessagingException; 
import javax.mail.Session; 
import javax.mail.Transport; 
import javax.mail.internet.InternetAddress; 
import javax.mail.internet.MimeMessage; 

import com.filenet.api.core.*; 
import com.filenet.api.engine.EventActionHandler; 
import com.filenet.api.events.ObjectChangeEvent; 
import com.filenet.api.exception.EngineRuntimeException; 
import com.filenet.api.exception.ExceptionCode; 
import com.filenet.api.util.Id; 

public class EMailAction implements EventActionHandler 
{ 
public void onEvent(ObjectChangeEvent event, Id subscriptionId) throws 
EngineRuntimeException 
{ 
Document doc = (Document)event.get_SourceObject(); 
try 
{ 
Properties props = new Properties(); 
props.put("mail.smtp.host", "smtp.company.net"); 
props.put("mail.smtp.port", "25"); 
Session session = Session.getInstance(props); 
try { 
Message msg = new MimeMessage(session); 
msg.setFrom(new InternetAddress("userl@company.com")); InternetAddress[] 
address = {new InternetAddress("sysAdmin@company.com")}; 
msg.setRecipients(Message.RecipientType.TO, address); 
msg.setSubject("Test E-Mail through Java"); 
msg.setSentDate(new Date()); 
msg.setText("Document " + doc.get_Name() + " created with ID " + doc.get_Id()); 
Transport.send(msg); 
} 
catch (MessagingException mex) { 
mex.printStackTrace();
 } 
} 
catch (Exception e) 
{ 
throw new EngineRuntimeException(ExceptionCode.E_FAILED); 
} 
} 
} 

 



Feedback

Letzte Aktualisierung: November 2010


© Copyright IBM Corp. 2010.
Dieses Information Center basiert auf Eclipse-Technologie. (http://www.eclipse.org)