Is there a way to get the value of the mail file field from the (Company)' Directory ? I wrote a code to get the value but it is not the same in all situation.
Here is the code:
var firstChar = context.getUser().getFullName().charAt(0);
var lastWord = context.getUser().getFullName().split(" ").pop();
var str = firstChar+lastWord;
var str2 = str.slice(0, 8);
var link = "https://server/mail/";
link +=str2+".nsf/iNotes/Mail/?OpenDocument&ui=portal";
return link;
You can access the server directory as any other Notes database. Unless additional address books are there, the user should exist under their username in the "($Users)" view. From there you can retrieve the mail file and server. If it's different from the current server, you may need to check the relevant server document for the hostname.
Borrowing an example from the documentation on the NotesDirectory class and modifying for your purposes, I'd try something like:
var mynotesdir:NotesDirectory = session.getDirectory("server name");
var homeserver = mynotesdir.GetMailInfo("Joe Smith", True);
var mailFileName = homeserver[3];
var link = "https://server/mail/" + mailFileName + "/iNotes/Mail/?OpenDocument&ui=portal";
return link;
The syntax may be wrong, as I copied it from an example and modified it here instead of in Designer, but this should still serve as a good start.....
Related
Previously i am sending a form as a doclink using #functions
Eg: #MailSend("Mary Tsen/";"";"";"Follow this link";"";"";[IncludeDocLink])
Please tell me how to send a mail message that includes a doclink in XPages using Serverside JavaScript.
thank you
The concept of a doclink in a web application don't exist. Therefore you must create an email and include a URL to the specific element. Not sure if using XPINC allows adding of a doclink.
email = database.createDocument();
email.replaceItemValue("Form", "Memo");
email.replaceItemValue("Subject","Test");
email.replaceItemValue("Body","You have email");
email.replaceItemValue("SendTo", sendto);
email.send(false);
In the past what I have done to include a link was to reconstruct the URL, as shown below, for the XPage and add that to the body of the message.
I used a viewPanel link for my scenario, but this should get you down the proper path.
var url:XSPUrl = context.getUrl();
var doc:NotesDocument = row.getDocument();
var unid = doc.getUniversalID();
var scheme = url.getScheme();
var host = url.getHost();
var db = database.getFilePath();
pdfurl = scheme + "://" + host + "/" + db + "/0/" + unid;
You can add a doclink to a rich text item using something like the code below.
var docEmail:NotesDocument = database.createDocument();
var rtitem:NotesRichTextItem = docEmail.createRichTextItem("Body");
docEmail.replaceItemValue("Form", "Memo");
docEmail.replaceItemValue("SendTo", "Your recipient");
docEmail.replaceItemValue("Subject", "Your Subject");
rtitem.appendText("Some text here... ");
rtitem.addNewLine(2);
rtitem.appendText("Click here to view the document => ");
rtitem.appendDocLink(thisdoc, "Some comment text");
rtitem.addNewLine(2);
docEmail.send();
I wired up SendGrid using their documentation as a guide. Nothing fancy here, just want to fire off an email for certain events. Looking at the code below, the SendGrid documentation directs me to use transportWeb.Deliver(message) but this results in "cannot resolve symbol Deliver" However if I use DeliverAsync everything works fine. Just seems sloppy to define a variable that is never used.
SendGridMessage message = new SendGridMessage();
message.AddTo(to);
message.From = new MailAddress(from);
message.Subject = subject;
message.Text = body;
var uid = AppConfigSettings.SendGridUid;
var pw = AppConfigSettings.SendGridPw;
var credentials = new NetworkCredential(uid, pw);
var transportWeb = new Web(credentials);
// transportWeb.Deliver(message); // "Deliver" won't resolve
var result = transportWeb.DeliverAsync(message);
Deliver() was removed in the most recent version of the library. Can you link me to the docs that are out of date?
I have a document that the user attaches a file to an upload control called licenseKey. In a SSJS I need to retrieve the content of that file and process it. I know that it is a ASCII text file and I know the general format. I would like to create var inStream:NotesStream for the content of the attachment, but I can't see how to do this in SSJS.
I have tried using getComponent("licenseKey") but don't see what might be next.
This code would actually be run by the user that attaches the file, so the local File Path and File Name would be valid if I could get them from the upLoad Control.
Thanks.
Julian Buss did a nice explanation
here. Quote:
How to process an uploaded file
Place code like this in the beforeRenderResponse event of an XPage to
get a handle to a just-uploaded file:
var con = facesContext.getExternalContext();
var request:com.sun.faces.context.MyHttpServletRequestWrapper = con.getRequest();
var map:java.util.Map = request.getParameterMap();
var fileDataName = "file"; //name of the POST request parameter that contains the file
var fileData:com.ibm.xsp.http.UploadedFile = map.get( fileDataName );
var tempFile:java.io.File = fileData.getServerFile();
The file is in the "xspupload" directory on the Domino Server and has
some crypting filename. You can get the original filename with
fileData.getClientFileName().
For example, you can attach the file to some Notes document with code
like this:
var correctedFile = new java.io.File( tempFile.getParentFile().getAbsolutePath() + java.io.File.separator +
fileData.getClientFileName() );
var success = tempFile.renameTo(correctedFile); //rtFiles is a rich text item on a notesdocument of your chosing
rtFiles.embedObject(lotus.domino.local.EmbeddedObject.EMBED_ATTACHMENT,
"", correctedFile.getAbsolutePath(), null);
correctedFile.renameTo(tempFile);
This snippet renames the temporary file to the orginal filename,
attaches it to a RichText item and renames it back to the cryptic name
(so that it will be deleted by Domino after processing).
Try this in beforerenderResponse:
var fileData:com.ibm.xsp.http.UploadedFile = facesContext.getExternalContext().getRequest().getParameterMap().get(getClientId('fileUpload1'));
if (fileData != null) {
var tempFile:java.io.File = fileData.getServerFile();
...
Names is not getting resolved while using HTML mail in xpages. Is it a problem with the snippet i took from xsnippet or problem with mime itself.
import ss_html_mail;
var mail = new HTMLMail();
var res:java.util.Vector = new java.util.Vector();
res.add("Soundararajan, Thirun");
res.add("Arumugam, Barath");
res.add("Selvam, Abirami")
res.add("Panneerselvam, Saravanan")
mail.setTo(res);
mail.setSubject("HTML Mail");
mail.addHTML("HTML Mail");
mail.send();
However if replace those names with email address or use default SSJS send function it is working. Default send() function resolves the names to email properly
res.add("Soundararajan.Thirun#gmail.com");
res.add("Arumugam.Barath#gmail.com");
res.add("Selvam.Abirami#gmail.com")
res.add("Panneerselvam.Saravanan#gmail.com")
or
var doc = database.createDocument();
var res:java.util.Vector = new java.util.Vector();
res.add("Soundararajan, Thirun");
res.add("Arumugam, Barath");
res.add("Selvam, Abirami")
res.add("Panneerselvam, Saravanan")
doc.replaceItemValue("Form", "Memo");
doc.replaceItemValue("Subject", "An email");
doc.replaceItemValue("SendTo", res);
doc.send();
I use this xsnippet all the time and the problem in your code is that you are using an vector to add the names in. Try to add the names in a Javascript array instead.
Like this
import ss_html_mail;
var mail = new HTMLMail();
var res=[]
res.push("Soundararajan, Thirun");
res.push("Arumugam, Barath");
res.push("Selvam, Abirami")
res.push("Panneerselvam, Saravanan")
mail.setTo(res);
mail.setSubject("HTML Mail");
mail.addHTML("HTML Mail");
mail.send();
I am trying to use Apache Thrift for passing messages between applications implemented in different languages. It is not necessarily used as RPC, but more for serializing/deserializing messages.
One application is in node.js. I am trying to figure out how Apache thrift works with node.js, but I can't find too much documentation and examples, except for one tiny one regarding Cassandra at:
https://github.com/apache/thrift/tree/trunk/lib/nodejs
Again, I don't need any procedures declared in the .thrift file, I only need to serialize a simple data structure like:
struct Notification {
1: string subject,
2: string message
}
Can anyone help me with an example?
I finally found the answer to this question, after wasting a lot of time just by looking at the library for nodejs.
//SERIALIZATION:
var buffer = new Buffer(notification);
var transport = new thrift.TFramedTransport(buffer);
var binaryProt = new thrift.TBinaryProtocol(transport);
notification.write(binaryProt);
At this point, the byte array can be found in the transport.outBuffers field:
var byteArray = transport.outBuffers;
For deserialization:
var tTransport = new thrift.TFramedTransport(byteArray);
var tProtocol = new thrift.TBinaryProtocol(tTransport);
var receivedNotif = new notification_type.Notification();
receivedNotif.read(tProtocol);
Also the following lines need to be added to the index.js file from the nodejs library for thrift:
exports.TFramedTransport = require('./transport').TFramedTransport;
exports.TBufferedTransport = require('./transport').TBufferedTransport;
exports.TBinaryProtocol = require('./protocol').TBinaryProtocol;
Plus there is also at least one bug in the nodejs library.
The above answer is wrong, because it tries to use outBuffers directly, which is an array of buffers. Here is a working example of using thrift with nodejs:
var util = require('util');
var thrift = require('thrift');
var Notification = require('./gen-nodejs/notification_types.js').Notification;
var TFramedTransport = require('thrift/lib/thrift/transport').TFramedTransport;
var TBufferedTransport = require('thrift/lib/thrift/transport').TBufferedTransport;
var TBinaryProtocol = require('thrift/lib/thrift/protocol').TBinaryProtocol;
var transport = new TFramedTransport(null, function(byteArray) {
// Flush puts a 4-byte header, which needs to be parsed/sliced.
byteArray = byteArray.slice(4);
// DESERIALIZATION:
var tTransport = new TFramedTransport(byteArray);
var tProtocol = new TBinaryProtocol(tTransport);
var receivedNotification = new Notification();
receivedUser.read(tProtocol);
console.log(util.inspect(receivedNotification, false, null));
});
var binaryProt = new TBinaryProtocol(transport);
// SERIALIZATION:
var notification = new Notification({"subject":"AAAA"});
console.log(util.inspect(notification, false, null));
notification.write(binaryProt);
transport.flush();
DigitalGhost is right, the previous example is wrong.
IMHO the outBuffers is a private property to the transport class and should not be accessed.