converting RIchText to Mime in java using domino designer - lotus-notes

Hi guys i am working Inline attachments(like images inside a mail body) in lotus notes.Based on the guidance on this question(can anyone please tell how to deal with inline images in lotus notes am trying to convert the Mail body from Richtext to MIME using.Domino version is 8.5.3
m_session.setConvertMIME(false);
doc.removeItem("$KeepPrivate");
doc.convertToMIME(doc.CVT_RT_TO_HTML,0);
MIMEEntity me=doc.getMIMEEntity("body");
The code is working fine when tried with agent.But when deployed in the server i am getting
NotesException: Conversion To MIME Failed:
[1FD8:0047-1DDC] 12-02-2014 18:30:23 HTTP JVM: HTMLAPI Problem converting to HTML.
When i searched all the material is saying this is a problem with lotus notes.can anyone please tell how to fix this.or is there any work around for this.Please help

I got a working RichText > Mime conversion script in ssjs, I guess this could be adapted to Java
function convertBodyToMimeAndSave(documentToConvert){
// Create a temporary document
// Calling convertToMime makes a MIME output of the full
/// document and puts it in body. If you have other
// fields than body in the original document, that
// will produce undesirable added content to the body
var tmp = database.createDocument();
// Put the original richtext in it
var rt = targetDocument.getFirstItem("Body")
if(!rt) return targetDocument
rt.copyItemToDocument(tmp)
// Convert the temporary document to MIME
tmp.convertToMIME(2)
// Copy all Items (that is, the Body) back to the original document
// (copying the Body specifically seemed to make the script crash)
tmp.copyAllItems (targetDocument, true)
targetDocument.closeMIMEEntities(true, "Body")
targetDocument.save()
}

Related

NetSuite SuiteScript 2.0 How to parse content Text in suitescript

i am trying to update a vendor record status field using suitescript 2.0,passing the body in postman tool and is working fine for content JSON but the problem is when i try content as Text its getting error don't know how to read body value in suitescript 2.0.
input body from postman
sample code is
function doPut(context)
{
var obj=JSON.stringify(context.ids);-----here is the error context is empty
// tried JSON.parse also getting undefined
log.debug('str: '+obj);
return obj;
}
If you could provide the exact error message that would be helpful.
But in the mean time a few things that you should verify in your script, if you do not pass application/JSON in header, and your data is object, you need to explicitly parse it into JSON(i.e use JSON.parse() on the request-body), and your response type too should be in the same format i.e your response type should match content-type in the request.
looks like you may have the wrong Content-type. Should be Application-json. If not try Json.parse on the body if you're using text/plain. First step is to always log the context to console or run Object.keys(context) to see what's there. Also make sure doPut is exported as a function

Node.js My XML is not reading my XSLT

My Node.js follows this format.
if(req.method =="POST"){ refineXML(req, result =>{
res.writeHead(200, {'Context-Type': 'text/xml'});
res.write(result);
res.end();
});
};
The refineXML code is a simple method that takes in an encoded xml string, decodes it, removes the id, and then sends it back to the user. When I console.log the result, the answer is in promper xml format. However, I can't figure out how to link it to my XSL document. My XSL document currently lies under my project->WebContent->XSL
My Console keeps printing out
TypeError: Cannot read property 'Symbol(asyncId)' of null
whatever that means while my firefox says
Error Loading stylesheet:The TLS handshake finished for ...
http://localhost:3000/my.xsl
What does the stylesheet declaration look like in your xml document?
should look something like:
<?xml-stylesheet href="my.xsl"?>
the href should be a relative path so if your xml is at my project->WebContent then the PI would be:
<?xml-stylesheet href="./XSL/my.xsl"?>
technically the leading ./ isn't needed but I find it aids clarity

Overriding EmailRecieved without loosing the Base EmailRecieved functionality

I have a document library setup to recieve emails. The emails coming in have a single picture and a csv file which I use for some processing.
The override emailrecieved works perfectly but of course as I override I lose the nice SharePoint functionaliy that saves the incomming email as configured in the settings.
It was my understanding that I could call MyBase.EmailRecieved in my event for the underlying functionality to still work. This however is not working and no record of the email coming in is getting retained.
For now I am explicitly creating an audit trail but I would like to rely on SharePoints existing functionality as I believe it will be more robust.
What am I doing wrong with the MyBase.EmailRecieved call? Or what can I do instead if this doesnt work?
Thanks in advance.
When writing your own EmailReceived event receiver you will loose the default functionality.
What you will have to do is to implement this default functionality yourself. Let me give you a simple example. The following example saves all mail attachments to the list if they are *.csv files. You can do the same with the emailMessage and save it to the list as well. As you can see it is as easy as to add Files.Add to add a file to a document library.
public override void EmailReceived(SPList list, SPEmailMessage emailMessage, string receiverData)
{
SPFolder folder = list.RootFolder;
//save attachments to list
foreach (SPEmailAttachment attachment in emailMessage.Attachments)
{
if (attachment.FileName.EndsWith(".csv"))
{
var attachmentFileName = attachment.FileName;
folder.Files.Add(folder.Url + "/" + attachmentFileName, attachment.ContentStream, true);
}
}
list.Update();
}

Updating multimedia component using TOM.NET

I am trying to update the metadata on the multimedia image in C# using Tridion's TOM.NET API like this
componentMM.LoadXML(localComponent.GetXML(XMLReadFilter.XMLReadALL));
// make changes to the component mm multimedia text;
localComponent.UpdateXML(componentMM.InnerXML);
localComponent.Save(True)
While this works for other components, it is failing for Multimedia images.
<?xml version="1.0"?>
<tcm:Error xmlns:tcm="http://www.tridion.com/ContentManager/5.0"
ErrorCode="80040345" Category="19" Source="Kernel" Severity="2">
<tcm:Line ErrorCode="80040345" Cause="false" MessageID="16137"><![CDATA[
Unable to save Component (tcm:33-32599).
]]><tcm:Token>RESID_4574</tcm:Token>
<tcm:Token>RESID_4418</tcm:Token>
<tcm:Token>tcm:33-32599</tcm:Token>
</tcm:Line>
<tcm:Line ErrorCode="80040345" Cause="true" MessageID="15747"><![CDATA[
Unexpected element: MultimediaFileSize
]]><tcm:Token>MultimediaFileSize</tcm:Token>
</tcm:Line>
<tcm:Details>
<tcm:CallStack>
<tcm:Location>ComponentBL.CheckMultiMediaProperties</tcm:Location>
<tcm:Location>ComponentBL.CheckMultiMediaProperties</tcm:Location>
<tcm:Location>ComponentBL.Update</tcm:Location>
<tcm:Location>XMLState.Save</tcm:Location>
<tcm:Location>Component.Save</tcm:Location>
</tcm:CallStack>
</tcm:Details>
</tcm:Error>
Can you please let me know what am I doing wrong here?
Thanks for your responses. I was deleting the node but at the wrong place. I update the code like this and it works fine now.
if (localComponent.IsMultimediaComponent)
{
XmlNode multimediaFileSizeNode = localComponentXML.SelectSingleNode("//*[local-name()='MultimediaFileSize']",tridionNamespace);
XmlNode dataNode = multimediaFileSizeNode.ParentNode;
dataNode.RemoveChild(multimediaFileSizeNode);
}
localComponent.UpdateXML(localComponentXML.InnerXml);
Include only the tcm:Metadata node in your update?
Specifically, it is complaining about you specifying the size of the mm file, which you shouldn't, that's a system property. Clean up the XML you receive from Tridion to remove that property (it might then complain about another property, just do what it asks you to).
EDIT: Reading the error messages is a great skill to have...
When you do this you need to only save the modified metadata data (not the entire XML). Try removing all of the child nodes except tcm:Metadata from the XML structure before calling .UpdateXML()
Perhaps you could paste your sample XML if you need further assistance.
I usually do this way:-
mComponent = (Component)mTDSE.GetObject("YOUR-COMPONENT-ID", EnumOpenMode.OpenModeView, null, XMLReadFilter.XMLReadAll);
mComponent.CheckOut(false);
mComponent.MetadataFields["YOUR-METADATA-FIELD-NAME"].value[1] = "VALUE TO BE REPLACED";
mComponent.Save(true);

raphael text() not working in ie9

Why is the following example not working in ie9?
http://jsfiddle.net/dzyyd/2/
It spits out a console error:
"Unexpected call to method or property access."
I found it pretty quickly. You created the element, but did not put it anywhere. Once it is added to the document body, everything seems to be fine.
this._width=300;
this._height=300;
this._bgSvgContainer = document.createElement("div");
//NOTE: add the created div to the body of the document so that it is displayed
document.body.appendChild(this._bgSvgContainer);
var bgCanvas = Raphael(this._bgSvgContainer, this._width, this._height);
this._bgCanvas = bgCanvas;
var num = this._bgCanvas.text(this._width-10,this._height-10,"1");
It's really hard to tell with such a tiny code-fragment (doesn't run on any browser for me), but it's probably a scope issue this in IE during events is completely different to this using the W3C event model. See: quirksmode-Event order-Problems of the Microsoft model

Resources