08-27-2013 08:42 AM
09-09-2013 07:52 AM
// Get document filename
Serializable filename = m_nodeService.getProperty(actionedUponNodeRef, ContentModel.PROP_NAME);
if (filename == null) {
throw new AlfrescoRuntimeException("Document filename is null");
}
String documentName = (String) filename;
try {
// Create mail session
Properties props = new Properties();
props.put("mail.smtp.host", "XXXXXX"); // localhost will not work
Session session = Session.getDefaultInstance(props, null);
session.setDebug(false);
// Define message
Message message = new MimeMessage(session);
String fromAddress = "alfresco@mycompany.com";
message.setFrom(new InternetAddress(fromAddress));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
message.setSubject(subject);
// Create the message part with body text
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setText(body);
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(messageBodyPart);
// Create the Attachment part
// Get the document content bytes
byte[] documentData = alfrescoRepoHelper.getDocumentContentBytes(actionedUponNodeRef, documentName);
if (documentData == null) {
throw new AlfrescoRuntimeException("Document content is null");
}
// Attach document
messageBodyPart = new MimeBodyPart();
messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(
documentData, new MimetypesFileTypeMap().getContentType(documentName))));
messageBodyPart.setFileName(documentName);
multipart.addBodyPart(messageBodyPart);
// Put parts in message
message.setContent(multipart);
// Send the message
Transport.send(message);
09-09-2013 08:45 AM
props.put("mail.smtp.host", "smtp.mycompany.com");
String fromAddress = "alfresco@mycompany.com";
09-09-2013 12:02 PM
15:18:13,521 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'sysAdmin' subsystem, ID: [sysAdmin, default]
15:18:13,552 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'sysAdmin' subsystem, ID: [sysAdmin, default] complete
15:18:23,162 INFO [org.springframework.extensions.webscripts.TemplateProcessorRegistry] Registered template processor Repository Template Processor for extension ftl
15:18:23,162 INFO [org.springframework.extensions.webscripts.ScriptProcessorRegistry] Registered script processor Repository Script Processor for extension js
15:18:26,594 INFO [org.alfresco.repo.domain.schema.SchemaBootstrap] Connecting to database: jdbc:mysql:///alfresco, UserName=alfresco@localhost, MySQL-AB JDBC Driver
15:18:26,594 INFO [org.alfresco.repo.domain.schema.SchemaBootstrap] Schema managed by database dialect org.hibernate.dialect.MySQLInnoDBDialect.
15:18:28,122 INFO [org.alfresco.repo.domain.schema.SchemaBootstrap] No changes were made to the schema.
15:18:29,230 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'Search' subsystem, ID: [Search, managed, lucene]
15:18:29,480 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'Search' subsystem, ID: [Search, managed, lucene] complete
15:18:30,400 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'thirdparty' subsystem, ID: [thirdparty, default]
15:18:32,756 WARN [org.alfresco.util.OpenOfficeConnectionTester] An initial OpenOffice connection could not be established.
15:18:32,756 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'OOoDirect' subsystem, ID: [OOoDirect, default] complete
15:18:33,255 WARN [org.alfresco.repo.admin.ConfigurationChecker] The Alfresco 'dir.root' property is set to a relative path './alf_data'. 'dir.root' should be overridden to point to a specific folder.
15:18:33,255 INFO [org.alfresco.repo.admin.ConfigurationChecker] The Alfresco root data directory ('dir.root') is: .\alf_data
15:18:33,442 INFO [org.alfresco.repo.admin.patch.PatchExecuter] Checking for patches to apply …
15:18:33,832 INFO [org.alfresco.repo.admin.patch.PatchExecuter] No patches were required.
15:18:33,848 INFO [org.alfresco.repo.module.ModuleServiceImpl] Found 1 module(s).
15:18:33,863 INFO [org.alfresco.repo.module.ModuleServiceImpl] Starting module 'alfresco-mm-repo' version 0.1.5.9.
15:18:33,863 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'fileServers' subsystem, ID: [fileServers, default]
15:18:34,316 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'Authentication' subsystem, ID: [Authentication, managed, alfrescoNtlm1]
15:18:34,409 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'Authentication' subsystem, ID: [Authentication, managed, alfrescoNtlm1] complete
15:18:34,550 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'fileServers' subsystem, ID: [fileServers, default] complete
15:18:34,550 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'imap' subsystem, ID: [imap, default]
15:18:34,987 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'imap' subsystem, ID: [imap, default] complete
15:18:34,987 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'email' subsystem, ID: [email, outbound]
15:18:35,018 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'email' subsystem, ID: [email, outbound] complete
15:18:35,018 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'email' subsystem, ID: [email, inbound]
15:18:35,080 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'email' subsystem, ID: [email, inbound] complete
15:18:35,080 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'googledocs' subsystem, ID: [googledocs, default]
15:18:35,127 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'googledocs' subsystem, ID: [googledocs, default] complete
15:18:35,127 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'Subscriptions' subsystem, ID: [Subscriptions, default]
15:18:35,127 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'Subscriptions' subsystem, ID: [Subscriptions, default] complete
15:18:35,127 INFO [org.alfresco.repo.usage.UserUsageTrackingComponent] Disabled - clear non-missing user usages …
15:18:35,143 INFO [org.alfresco.repo.usage.UserUsageTrackingComponent] Found 1 users to clear
15:18:35,626 INFO [org.alfresco.repo.usage.UserUsageTrackingComponent] … cleared non-missing usages for 1 users
15:18:35,626 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'Synchronization' subsystem, ID: [Synchronization, default]
15:18:35,704 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'Synchronization' subsystem, ID: [Synchronization, default] complete
15:18:35,798 INFO [org.alfresco.service.descriptor.DescriptorService] Alfresco JVM - v1.7.0-b147; maximum heap size 989.875MB
15:18:35,798 INFO [org.alfresco.service.descriptor.DescriptorService] Alfresco started (Community). Current version: 4.2.0 (@build-number@) schema 6,020. Originally installed version: 4.2.0 (@build-number@) schema 6,020.
15:18:35,798 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'ActivitiesFeed' subsystem, ID: [ActivitiesFeed, default]
15:18:35,860 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'ActivitiesFeed' subsystem, ID: [ActivitiesFeed, default] complete
15:18:35,860 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Starting 'Replication' subsystem, ID: [Replication, default]
15:18:35,860 INFO [org.alfresco.repo.management.subsystems.ChildApplicationContextFactory] Startup of 'Replication' subsystem, ID: [Replication, default] complete
15:18:36,141 DEBUG [org.alfresco.repo.action.executer.MailActionExecuter] {template_model={repeatIntervalMins=1440, feedItemsCount=1, feedItemsMax=100, activities=[{id=7, siteNetwork=demo, feedUserId=nancy, postUserId=nancy, postDate=Tue Sep 10 13:04:09 IST 2013, activitySummary={lastName=aggarwal, title=nancy aggarwal (nancy), memberLastName=aggarwal, role=SiteCollaborator, firstName=nancy, memberUserName=nancy, memberFirstName=nancy}, activityType=org.alfresco.site.user-joined, activitySummaryFormat=json}], productName=Share, siteTitles={demo=demo}, personProps={cm:lastName=aggarwal, sys:node-uuid=1aa6f015-48dd-47eb-b844-601b53ec5782, cm:firstName=nancy, cm:name=1aa6f015-48dd-47eb-b844-601b53ec5782, sys:locale=en_US, cm:owner=nancy, sys:store-protocol=workspace, cm:userName=nancy, cm:homeFolderProvider=userHomesHomeFolderProvider, sys:node-dbid=857, cm:sizeQuota=-1, cm:sizeCurrent=null, cm:email=XXXXXX, cm:homeFolder=workspace://SpacesStore/, sys:store-identifier=SpacesStore}}, template=workspace://SpacesStore/, to=xxxxxx, subject=Alfresco Share: Recent Activities}
15:18:40,899 INFO [org.springframework.extensions.webscripts.DeclarativeRegistry] Registered 470 Web Scripts (+0 failed), 749 URLs
15:18:40,899 INFO [org.springframework.extensions.webscripts.DeclarativeRegistry] Registered 2 Package Description Documents (+0 failed)
15:18:40,899 INFO [org.springframework.extensions.webscripts.DeclarativeRegistry] Registered 1 Schema Description Documents (+0 failed)
15:18:40,899 INFO [org.springframework.extensions.webscripts.AbstractRuntimeContainer] Initialised Repository Web Script Container (in 4342.737ms)
15:18:40,930 INFO [org.springframework.extensions.webscripts.TemplateProcessorRegistry] Registered template processor freemarker for extension ftl
15:18:40,930 INFO [org.springframework.extensions.webscripts.ScriptProcessorRegistry] Registered script processor javascript for extension js
09-10-2013 01:12 PM
09-11-2013 07:35 AM
09-11-2013 10:13 AM
<config evaluator="string-compare" condition="send-as-email">
<forms>
<form>
<field-visibility>
<show id="to" />
<show id="subject" />
<show id="body_text" />
</field-visibility>
<appearance>
<field id="to" label-id="send-as-email.field.to"/>
<field id="subject" label-id="send-as-email.field.subject"/>
<field id="body_text" label-id="send-as-email.field.text"/>
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</appearance>
</form>
</forms>
</config>
public class SendAsEmailActionExecuter extends ActionExecuterAbstractBase {
private static Log logger = LogFactory.getLog(SendAsEmailActionExecuter.class);
// Form parameters
public static final String PARAM_EMAIL_TO_NAME = "to";
public static final String PARAM_EMAIL_SUBJECT_NAME = "subject";
public static final String PARAM_EMAIL_BODY_NAME = "body_text";
props.put("mail.smtp.host", "alfea-port-1103");
and line 87 -
String fromAddress = "alfresco@alfea-port-1103.com";
logger.debug("my message");
log4j.logger.com.mycompany.cms.action.SendAsEmailActionExecuter=debug
09-12-2013 12:57 AM
<config evaluator="string-compare" condition="send-as-email">
<forms>
<form>
<field-visibility>
<show id="to" />
<show id="subject" />
<show id="body_text" />
</field-visibility>
<appearance>
<field id="to" label-id="send-as-email.field.to"/>
<field id="subject" label-id="send-as-email.field.subject"/>
<field id="body_text" label-id="send-as-email.field.text"/>
<control template="/org/alfresco/components/form/controls/textarea.ftl" />
</appearance>
</form>
</forms>
</config>
props.put("mail.smtp.host", "smtp.mycompany.com");
String fromAddress = "alfresco@org.com";
logger.debug("my message");
log4j.logger.com.mycompany.cms.action.SendAsEmailActionExecuter=debug
09-12-2013 03:36 AM
09-12-2013 06:56 AM
<bean id="send-as-email" class="com.mycompany.cms.action.SendAsEmailActionExecuter" parent="action-executer">
<property name="alfrescoRepoHelper">
<ref bean="alfrescoRepoHelper"/>
</property>
<property name="nodeService">
<ref bean="NodeService"/>
</property>
</bean>
09-13-2013 10:42 AM
// you can use whatever document node you want, nothing is done with that document !
var document = utils.getNodeFromString("workspace://SpacesStore/1560d1bb-80fa-43f6-87bf-6937b085407e");
var mail = actions.create("send-as-email");
mail.parameters.to = "recipient@email.address";
mail.parameters.subject = "Sending mail test";
mail.parameters.from = "sender@email.address";
mail.parameters.body_text = "email content";
mail.parameters.node = document;
mail.execute(document);
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.