cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1267
Views
5
Helpful
0
Comments
Orf Gelbrich
Cisco Employee
Cisco Employee
Task Name

Send e-mail with attachment file from UCSD

Description

Prerequisites
  1. Tested on 5.4
CategoryWorkflow
ComponentsvSphere 5.x
User Inputse-mail address
Outpute-mail with counter

Instructions for Regular Workflow Use:

  1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
  2. Unzip the file on your computer. Should end up with a .WFD file.
  3. Log in to UCS Director as a user that has "system-admin" privileges.
  4. Navigate to "Policies-->Orchestration" and click on "Import".
  5. Click "Browse" and navigate to the location on your computer where the .WFDX file resides. Choose the .WFDX file and click "Open".
  6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
  7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
  8. Click "Submit".
  9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment

A thank you goes out to Tejeswar Sahu

The task inputs:

Unknown.png

The resulting e-mail:

Unknown-1.png

The Code in the custom task:

importPackage(com.cloupia.lib.util.mail);

importPackage(com.cloupia.feature.cloudsense);//CloudSenseUtil

importPackage(java.lang);

importPackage(java.io);

importPackage(java.net);

importPackage(javax.mail);

importPackage(javax.mail.internet);//MimeBodyPart

importPackage(javax.activation);//FileDataSource

////////  FOR SENDING MAIL WITH ATTACHING THE FILE /////////////////////

var fullPathOfFile = input.location;

var toAddress = input.address;

var subject = input.subject;

var body = input.body;

var mailSettings = CloudSenseUtil.getMailSettings();

var fromAddr = mailSettings.getFromEmailAddress();

logger.addInfo("from address : " + fromAddr+":::"+"to address : " + toAddress+":::"+"Subject:"+subject);

logger.addInfo(mailSettings.getFromEmailAddress()+":"+mailSettings.getSmtpServer()+":"+mailSettings.getSmtpUser()+":"+

mailSettings.getSmtpPass()+":"+mailSettings.getSmtpPort());

var sourceFile = new File(fullPathOfFile);

var messageBodyPart = new MimeBodyPart();

messageBodyPart.setText(body);

var multipart = new MimeMultipart();

multipart.addBodyPart(messageBodyPart);

messageBodyPart = new MimeBodyPart();

var pdfFile = new File(sourceFile);

var fds = new FileDataSource(pdfFile);

messageBodyPart.setDataHandler(new DataHandler(fds));

var fileName = pdfFile.getName();

logger.addInfo("File name is :"+fileName+":");

messageBodyPart.setFileName(fileName);

multipart.addBodyPart(messageBodyPart);

MailManager.sendEmailBuiltIn(mailSettings, multipart, fromAddr, subject, toAddress);

logger.addInfo("Message sent successfully.");

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links