CarbonCopy to a gmail address doesn't seem to work - java

I'm using a DocuSign Java SDK and need the functionality of CarbonCopy as I need to send every document to a person within our company other than a Signer.
So when I use the gmail address for the Signer the email is sent. But when I use the gmail address for the CarbonCopy recipient the email is never sent and I do not get an error. The envelope id is returned as if everything went fine.
Is there anything that I'm missing? Is it possible to make that work?
// login call available off the AuthenticationApi
AuthenticationApi authApi = new AuthenticationApi();
// login has some optional parameters we can set
AuthenticationApi.LoginOptions loginOps = authApi.new LoginOptions();
loginOps.setApiPassword("true");
loginOps.setIncludeAccountIdGuid("true");
LoginInformation loginInfo = authApi.login(loginOps);
// note that a given user may be a member of multiple accounts
List<LoginAccount> loginAccounts = loginInfo.getLoginAccounts();
String accountId = loginAccounts.get(0).getAccountId();
Path path = Paths.get(sFilePath);
byte[] PDFContents = Files.readAllBytes(path);
// Create an envelope that will store the document(s), field(s), and recipient(s)
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.setEmailSubject("Please sign this document sent from Java SDK)");
// Add a document to the envelope
Document doc = new Document();
String base64Doc = DatatypeConverter.printBase64Binary(PDFContents);
doc.setDocumentBase64(base64Doc);
doc.setName("MaterialRequisition.pdf"); // can be different from actual file name
doc.setDocumentId("1");
List<Document> docs = new ArrayList<Document>();
docs.add(doc);
envDef.setDocuments(docs);
// add a recipient to sign the document, identified by name and email we used above
Signer signer = new Signer();
signer.setEmail(sApproverEmail);
signer.setName(sApproverName);
signer.setRecipientId("1");
CarbonCopy cc = new CarbonCopy();
cc.setEmail(sCCEmail);
cc.setName(sCCName);
cc.setRecipientId("2");
// create a signHere tab somewhere on the document for the signer to sign
// default unit of measurement is pixels, can be mms, cms, inches also
SignHere signHere = new SignHere();
signHere.setDocumentId("1");
signHere.setPageNumber("1");
signHere.setRecipientId("1");
signHere.setXPosition("100");
signHere.setYPosition("710");
// Can have multiple tabs, so need to add to envelope as a single element list
List<SignHere> signHereTabs = new ArrayList<SignHere>();
signHereTabs.add(signHere);
Tabs tabs = new Tabs();
tabs.setSignHereTabs(signHereTabs);
signer.setTabs(tabs);
// add recipients (in this case a single signer) to the envelope
envDef.setRecipients(new Recipients());
envDef.getRecipients().setSigners(new ArrayList<Signer>());
envDef.getRecipients().getSigners().add(signer);
envDef.getRecipients().getCarbonCopies().add(cc);
// send the envelope by setting |status| to "sent". To save as a draft set to "created"
envDef.setStatus("sent");
// instantiate a new EnvelopesApi object
EnvelopesApi envelopesApi = new EnvelopesApi();
// call the createEnvelope() API to send the signature request!
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
logger.debug("Envelope Id "+ envelopeSummary.getEnvelopeId());
// Delete the PDF file that Logi generated
Files.delete(path);

CarbonCopy recipients will receive email only when the envelope gets completed by all the parties based on the recipient’s order. Have a look at the Carbon Copies Recipient description in this link.
Debug the code and make sure whether CarbonCopy values gets added inside the envDef.getRecipients().getCarbonCopies() before it hits the createEnvelope and when the full envelope process gets completed by the signer thereafter a copy will be sent to the carbon copy recipient mail address, to make sure of that sign into the CarbonCopy recipient email address an email must be received along with completed document where you can only view the document..

Related

How to create com.microsoft.graph.models.Message with attachment?

I'm trying to send email with inline attachment using MS Graph. I know how to send email without attachment but when I'm trying to send message with attachment I don't know how can I add this attachment to the message.
Here is my code:
// recipients
Recipient recipient = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.address = "tom#mail.com";
recipient.emailAddress = emailAddress;
List<Recipient> recipients = List.of(recipient);
// body
ItemBody body = new ItemBody();
body.contentType = BodyType.HTML;
body.content = "<html><body>my image:<br><img src='cid:my_image_CID'></body></html>";
// inline image
Attachment attachment = new Attachment();
attachment.isInline = true;
attachment.contentType = ".png";
attachment.id = "my_image_CID";
//attachment.contentBytes - I DON'T SEE THIS FIELD...
// message
Message message = new Message();
message.subject = "my subject";
message.body = body;
message.toRecipients = recipients;
//message.attachments = ??? - how to create this object?
there are examples in the internet that I can set attachment.contentBytes but I don't see this attribute.
For the message I can set attachments object which is of type
AttachmentCollectionPage
but I don't know how can I create this object.
I'm using the following versions:
Microsoft Graph Java SDK » 5.42.0
Microsoft Graph Java Core SDK » 2.0.14
You need to use FileAttachment which extends Attachment and has property contentBytes.

Create email (outlook format) on web-service side (Java) and send to front end and download

I want to write a service through which I can create a email message with (to, cc, bcc, subject, body) specified. Then I need to return this email message to front end and download it in ".oft" format, in such a way that when I click on this downloaded file; file should open with all the fields (to, cc, bcc, subject, body) populated.
I am using Java as backend technology and angular5 as front-end.
I have tried using javax.mail utility to create the email message and return it as byte array. Something like:
Properties prop = System.getProperties();
Session session = Session.getDefaultInstance(prop, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("emailAddr#domain.com"));
msg.addRecipient(Message.RecipientType.TO, new InternetAddress("emailAddr#domain.com"));
msg.setSentDate(new Date());
msg.setSubject("subject");
msg.setText("text of msg");
//return it from service API as
response.getOutputStream().write(msg.toString().getBytes());
On front end (component.ts file) I am retrieving the response as :
//function gets called on button click
createEmailTemplate():void{
this.httpService.getEmail('serviceUrl')
.subscribe(
email => {
let filename = "SampleMailFile.oft";
let linkElement = document.createElement('a');
let blob = new Blob([email], { type: "message/rfc822"});
let url = window.URL.createObjectURL(blob);
linkElement.setAttribute('href', url);
linkElement.setAttribute("download", filename);
let clickEvent = new MouseEvent("click", {
"view": window,
"bubbles": true,
"cancelable": false
});
linkElement.dispatchEvent(clickEvent);
}
);
}
A MSG file is supposed to have the same format as an OFT file. If that’s true then you should be able to use jotlmsg to generate the file. You shouldn’t need to use JavaMail at all for this, since it’s intended to actually send the mail.
NOTE: I’ve not used this library before, so I can’t speak to whether this will truly work.

Adding Personalized data to MQ RFH2 Header

HI i am trying to add data in the RFH2 MQ header.
The format for the data which i want is:
struc id : RFH
version:2
encoding:546
CodedCharSetid:437
Format:MQSTR
Flags:0
NameValeCCSID:1208
NamevalueLen:56
Namevaluedata:<mcd><msd>jms_text<Msd><Type>Hello</type></mcd>
NamvalueLen:56
NameValuedata:<jms><dst></dst></jms>
NamevalueLen:56
NameValuedata:<usr>Hi</usr>
I have the following code, but i am not understanding how to add the NameValueLen and NAMEVALUEDATA part. Can some check the code which i have written and guide me further on this?
MQMessage msg = new MQMessage();
msg.format = MQC.MQFMT_RF_HEADER_2; // Msg Format
msg.writeString(MQC.MQRFH_STRUC_ID); // StrucId
msg.writeInt4(MQC.MQRFH_VERSION_2); // Version
msg.writeInt4(MQC.MQRFH_STRUC_LENGTH_FIXED_2 + folderLength + 4);
msg.writeInt4(MQC.MQENC_NATIVE); // Encoding
msg.writeInt4(MQC.MQCCSI_DEFAULT); // CodedCharacterSetId
msg.writeString(MQC.MQFMT_NONE); // Format (content)
msg.writeInt4(MQC.MQRFH_NO_FLAGS); // Flags
msg.writeInt4(1208); // NameValueCCSID = UTF-8
I don't know what tool you are using but it is confusing the issue. MQRFH2 has "folders". The 1st folder is ALWAYS "mcd". The 2nd folder is "jms". All folders after that are optional.
Note: The "usr" folder is where you put your user data.
Why are you not using the MQRFH2 class in MQ?
https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_8.0.0/com.ibm.mq.dev.doc/q030950_.htm
i.e. Here's how you should be doing it:
MQMessage mqMsg = new MQMessage();
MQRFH2 rfh2 = new MQRFH2();
rfh2.setEncoding(CMQC.MQENC_NATIVE);
rfh2.setCodedCharSetId(CMQC.MQCCSI_INHERIT);
rfh2.setFormat(CMQC.MQFMT_STRING);
rfh2.setNameValueCCSID(1208);
rfh2.setFieldValue("usr", "somefield", "somedata");
try
{
rfh2.write(mqMsg);
}
catch (IOException e)
{
System.err.println(e.getLocalizedMessage());
}
Note: In the above code, folders "mcd" and "jms" will be automatically created and populated.
You can blast all 3 folders ("mcd", "jms" and "usr") in 1 shot. I don't recommend it unless you know what you are doing.
rfh2.setFolderStrings(new String[]{"<mcd><Msd>jms_text</Msd></mcd>",
"<jms><Dst>queue:///TEST.Q1</Dst><Pri>0</Pri></jms>",
"<usr><somefield>somedata</somefield></usr>"});

XML Signature is not valid - XML SignatureValue differs in C# and Java code

We use a BizTalk solution to sign and send a message headers, the problem is that the signature according to recipient is no valid, this recipient has a JAVA workshop.
The existing code today is written in Java , that works, and we want to migrate it to C# code
Bellow is one of the message headers signed , in JAVA code, and that works, check the DigestValue
Here is the same header signed in C# code that does not work and as you can see same DigestValue but different SignatureValue. The only difference i can see , in the signature that works, is that the certificate has carriage returns every 76 chars.
Here is the C# code i use to Sign the headers, certificate is globally assigned
The xmlDoc is created with PreserveWhitespace = true;
private void SignXml(XmlDocument xmlDoc, string referenceURI)
{
// Check arguments.
if (xmlDoc == null)
throw new ArgumentException("xmlDoc");
if (certificate == null)
throw new ArgumentException("Key");
// Create a SignedXml object.
SignedXml signedXml = new SignedXml(xmlDoc);
// Add the key to the SignedXml document.
signedXml.SigningKey = certificate.PrivateKey;
signedXml.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigExcC14NTransformUrl;//NEW
// Create a reference to be signed.
Reference reference = new Reference();
reference.Uri = String.Format("#{0}", referenceURI);
// Add an enveloped transformation to the reference.
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
reference.AddTransform(env);
XmlDsigExcC14NTransform c14trf = new XmlDsigExcC14NTransform(false, "xs");
//might need some InclusiveNamespaces
c14trf.Algorithm = SignedXml.XmlDsigExcC14NTransformUrl;
reference.AddTransform(c14trf);
// Add the reference to the SignedXml object.
signedXml.AddReference(reference);
//AddKeyInfo value, optional in standard
KeyInfo keyInfo = new KeyInfo();
KeyInfoX509Data keyinfoData = new KeyInfoX509Data(certificate);
keyInfo.AddClause(keyinfoData);
signedXml.KeyInfo = keyInfo;
// Compute the signature.
signedXml.ComputeSignature();
// Get the XML representation of the signature and save
// it to an XmlElement object.
XmlElement xmlDigitalSignature = signedXml.GetXml();
if (signedXml.CheckSignature(certificate, true) == false)
{
throw new ArgumentException("INT0014a Signature is incorrect", "CheckSignature");
}
// Append the element to the XML document.
xmlDoc.DocumentElement.InsertAfter(xmlDoc.ImportNode(xmlDigitalSignature,true), xmlDoc.DocumentElement.FirstChild);
}
Any help is appreciated

how to send url in email without encoding

I am using Amazon Simple Email Service java API to send mail to receivers.
I am sending URL in mail body inside tag.
My use case demands the user to double click on the URL received to prompt some action. (like confirmation mail)
Problem is the url gets encoded while receiving. On double clicking it gives page not found (404) error.
Original URL : http://something.com/confirm/email=abc#hotmail.com&regKey=somekey&confirm=true
When i double click on this URL on mail, the link is opened in address bar as :
http://something.com/confirm/email=abc%40hotmail.com%26regKey=somekey%26confirm=true
I am using AmazonSimpleEmailServiceClient. Code is below :
SendEmailRequest request = new SendEmailRequest().withSource(sourceAddress);
String confirmationURL="http://something.com/confirm/email=abc#hotmail.com&regKey=somekey&confirm=true";
List<String> toAddresses = new ArrayList<String>();
toAddresses.add(toEmail);
Destination dest = new Destination().withToAddresses(toAddresses);
request.setDestination(dest);
Content subjContent = new Content().withData("Confirmation Request");
Message msg = new Message().withSubject(subjContent);
// Include a body in both text and HTML formats
Content textContent = new Content().withData("Dear please go to the following URL:"+
confirmationURL+"\n\n");
Content htmlContent = new Content().withData("<p>Dear please go to the following URL:</p>"+
"<p>"+confirmationURL+"</p>");
Body body = new Body().withHtml(htmlContent).withText(textContent);
msg.setBody(body);
request.setMessage(msg)
UPDATE
Just found, this problem is occurring only when recipient email is in hotmail.com. Why microsoft always have to do something differently ? Somebody help !
Use the class java.net.URLEncoder:
String confirmationURL = URLEncoder.encode( "http://something.com/confirm/email=abc#hotmail.com&regKey=somekey& confirm=true", "UTF-8");

Categories

Resources