VMware Cloud Community
mg1978
Enthusiast
Enthusiast
Jump to solution

How sending attachment from vCO server per mail

Hi All,

I try to send an attachment from my vCO server. I have a csv file which will be created from a workflow and I will send this file as attachment per mail.

I found this here --> https://communities.vmware.com/thread/440886?start=0&tstart=0

But can somebody help me how I can implamented  this here "reseourceElement.getContentAsMimeAttachment() method" in the "Send notification" workflow: I try this here, but it is not working how I need it.

var message = new EmailMessage();

// Override default settings if and only if input parameter is set

if ( smtpHost != null && smtpHost.length > 0 ){

message.smtpHost = smtpHost;

}

if ( smtpPort != null && smtpPort > 0 ){

message.smtpPort = smtpPort;

}

if ( username !=null && username.length > 0){

message.username = username;

}

if ( password != null && password.length > 0){

message.password = password;

}

if ( fromName != null && fromName.length > 0){

message.fromName = fromName;

}

if ( fromAddress != null && fromAddress.length > 0){

message.fromAddress = fromAddress;

}

message.toAddress = toAddress;

message.subject = subject;

message.addMimePart(content,"text/html; charset=UTF-8");

//Create Attachment

var fileAttachment = new MimeAttachment();

fileAttachment.name = attachmentName;

fileAttachment.content = attachment;

message.addMimePart(fileAttachment,"text/html; charset=UTF-8");

System.log( "sending mail to host: " + message.smtpHost + ":" + message.smtpPort + " with user:" + message.username

   + ", from:" + message.fromAddress + ", to:" + message.toAddress );

message.sendMessage

Thanks.

0 Kudos
1 Solution

Accepted Solutions
Burke-
VMware Employee
VMware Employee
Jump to solution

Assuming you have a resource element mapped to your workflow as an attribute (or Input) named "resourceElement" and that "content" is a string variable containing the body content, the following adjustment should be made - Going by memory here, but this should be close...:

var fileAttachment = resourceElement.getContentAsMimeAttachment();

message.addMimePart(content,"text/html; charset=UTF-8");

message.addMimePart(fileAttachment, fileAttachment.mimeType);

message.sendMessage();

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter

View solution in original post

0 Kudos
1 Reply
Burke-
VMware Employee
VMware Employee
Jump to solution

Assuming you have a resource element mapped to your workflow as an attribute (or Input) named "resourceElement" and that "content" is a string variable containing the body content, the following adjustment should be made - Going by memory here, but this should be close...:

var fileAttachment = resourceElement.getContentAsMimeAttachment();

message.addMimePart(content,"text/html; charset=UTF-8");

message.addMimePart(fileAttachment, fileAttachment.mimeType);

message.sendMessage();

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you!

Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator
for vRealize Orchestrator tips and tutorials - @TechnicalValues on Twitter
0 Kudos