Send Vote options with Microsoft Graph API - microsoft-graph-api

Is there a way, in Microsoft Graph API, using singleValueExtendedProperties or multiValueExtendedProperties, to send an email with voting options?
I can do it with using Microsoft.Exchange.WebServices and the following code, but I need a way to do it in Microsoft Graph API
public byte[] StringToByteArray(string hex)
{
if (hex.Length % 2 == 1)
throw new Exception("The binary key cannot have an odd number of digits");
byte[] arr = new byte[hex.Length >> 1];
for (int i = 0; i < hex.Length >> 1; ++i)
{
arr[i] = (byte)((GetHexVal(hex[i << 1]) << 4) + (GetHexVal(hex[(i << 1) + 1])));
}
return arr;
}
public int GetHexVal(char hex)
{
int val = (int)hex;
//For uppercase A-F letters:
//return val - (val < 58 ? 48 : 55);
//For lowercase a-f letters:
//return val - (val < 58 ? 48 : 87);
//Or the two combined, but a bit slower:
return val - (val < 58 ? 48 : (val < 97 ? 55 : 87));
}
public void TestEmail()
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
service.Credentials = new WebCredentials("xxxxxx#xxxxxx.xxx", "xxxxxxxxx");
service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
EmailMessage email = new EmailMessage(service);
email.ToRecipients.Add("xxx#xxxxxxx.xxx");
email.Subject = "Approval test from C#";
email.ReplyTo.Add("xxx#xxxxxxx.xxx");
string Header = "02010600000000000000";
string ReplyToAllHeader = "055265706C790849504D2E4E6F7465074D657373616765025245050000000000000000";
string ReplyToAllFooter = "0000000000000002000000660000000200000001000000";
string ReplyToHeader = "0C5265706C7920746F20416C6C0849504D2E4E6F7465074D657373616765025245050000000000000000";
string ReplyToFooter = "0000000000000002000000670000000300000002000000";
string ForwardHeader = "07466F72776172640849504D2E4E6F7465074D657373616765024657050000000000000000";
string ForwardFooter = "0000000000000002000000680000000400000003000000";
string ReplyToFolderHeader = "0F5265706C7920746F20466F6C6465720849504D2E506F737404506F737400050000000000000000";
string ReplyToFolderFooter = "00000000000000020000006C00000008000000";
string ApproveOption = "0400000007417070726F76650849504D2E4E6F74650007417070726F766500000000000000000001000000020000000200000001000000FFFFFFFF";
string RejectOtion = "040000000652656A6563740849504D2E4E6F7465000652656A65637400000000000000000001000000020000000200000002000000FFFFFFFF";
string VoteOptionExtras = "0401055200650070006C00790002520045000C5200650070006C007900200074006F00200041006C006C0002520045000746006F007200770061007200640002460057000F5200650070006C007900200074006F00200046006F006C00640065007200000741007000700072006F00760065000741007000700072006F007600650006520065006A0065006300740006520065006A00650063007400";
string DisableReplyAllVal = "00";
string DisableReplyVal = "00";
string DisableForwardVal = "00";
string DisableReplyToFolderVal = "00";
email.Body = new MessageBody();
email.Body.BodyType = BodyType.HTML;
email.Body.Text = "Body";
ExtendedPropertyDefinition VOTE_DEF = new ExtendedPropertyDefinition(Microsoft.Exchange.WebServices.Data.DefaultExtendedPropertySet.Common, 0x8520, Microsoft.Exchange.WebServices.Data.MapiPropertyType.Binary);
byte[] bytes = StringToByteArray(Header + ReplyToAllHeader + DisableReplyAllVal + ReplyToAllFooter + ReplyToHeader + DisableReplyVal + ReplyToFooter + ForwardHeader + DisableForwardVal + ForwardFooter + ReplyToFolderHeader + DisableReplyToFolderVal + ReplyToFolderFooter + ApproveOption + RejectOtion + VoteOptionExtras);
email.SetExtendedProperty(VOTE_DEF, bytes);
email.SendAndSaveCopy();
}

Yes using EWS API you can do this. But i failed to notice any documentation how to do so. Being said that i remember a related thread talks about this and see how you can use MAPI extended properties. If nothing works, consider filing an uservoice item(feature request) with Microsoft Graph team, so that they can consider implementing it.

Related

GAS : How to check if a file exists in a specific folder and if so go to the next iteration

I'm writing a script that does the following :
send an email with an attachment (eg proof of payment) to people that register for our event when two criteria are met: payment has been processed, and if they have not yet received their proof of payment
make a copy of an existing file, using some variables in the new copy (this works fine) to personalize the proof of payment.
The copy of the file gets a new name (personalized).
I seem to be unable to make the script check correctly if the file already exists or not.
Who can help me out ?
function createDocument(e) {
var headers = Sheets.Spreadsheets.Values.get('SHEET ID', 'Lijst!A1:G');
var lid = Sheets.Spreadsheets.Values.get('SHEET ID', 'Lijst!A2:G');
var templateId = 'TEMPLATE ID';
for (var j = 0; j < lid.values.length; j++) {
if (lid.values[j][6] == 'ok' && lid.values[j][7] != 'Bewijs Verzonden') {
//collect the data from the member
var voornaam = lid.values[j][0];
var familienaam = lid.values[j][1];
var email = lid.values[j][2];
var aantal = lid.values[j][3];
var betaaldop = lid.values[j][5];
//Make a copy of the template file
var documentId = DriveApp.getFileById(templateId).makeCopy().getId();
var doc = DriveApp.getFileById(documentId);
var docname = 'Betalingsbewijs Reunie 2019 voor ' + familienaam + ' ' + voornaam + '.pdf';
//var filecheck = DriveApp.getFolderById('FOLDER ID');
var filecheck = DriveApp.getFilesByName(docname);
if (filecheck.hasNext()) {
Logger.log("No File Found");
} else {
//Get the document body as a variable
var body = DocumentApp.openById(documentId).getBody();
//Insert the data from spreadsheet
body.replaceText('<<Voornaam>>', voornaam)
body.replaceText('<<Naam>>', familienaam)
body.replaceText('<<Aantal deelnemers>>', aantal)
body.replaceText('<<Betaald op>>', betaaldop)
DocumentApp.openById(documentId).saveAndClose();
//move file to new folder and remove from parent folder
var file = DriveApp.getFileById(documentId);
file.getParents().next().removeFile(file);
DriveApp.getFolderById('FOLDER ID').addFile(file);
var pdfname = file.setName('Betalingsbewijs Reunie 2019 voor ' + familienaam + ' ' + voornaam + '.pdf');
var steil = "email#gmail.com";
var blob = pdfname.getBlob().getAs('application/pdf');
var subject = 'Betalingsbewijs Reunie 2019 voor ' + familienaam + ' ' + voornaam + ' met ' + aantal + 'deelnemer(s)';
var htmlBody =
"Beste " + voornaam + ", " +
"<br/>" +
"<br/>" +
"<br/>Bedankt voor uw inschrijving voor de Steil reünie op zaterdag 26 januari 2019." +
"<br/>Wij hebben uw betaling goed ontvangen." +
"<br/>Uw deelname aan de reünie is nu definitief in orde." +
"<br/>In bijlage kan u uw betalingsbewijs terugvinden in pdf." +
"<br/><br/>Indien u nog vragen heeft kan u ons steeds bereiken via reunie.steil#gmail.com." +
"<br/>Met verplegende groeten," +
"<br/>Het Steil Reünie team";
var optAdvancedArgs = {
name: "Steil Reünie 2019",
htmlBody: htmlBody,
replyTo: email,
cc: steil,
attachments: [blob]
};
GmailApp.sendEmail(email, subject, body, optAdvancedArgs);
var ConfirmationRange = "Lijst!H" + [j + 2];
SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange(ConfirmationRange).setValue('Bewijs Verzonden');
}
}
}
}

QuickBooks Desktop Integration

I have a task to make a syncing service that can sync the sales records present in the Quick books point of sale into the local database.
How to integrate Quick books desktop point of sale and web application(c#) via web connector?
Code used :
public string sendRequestXML(string ticket, string strHCPResponse, string
strCompanyFileName,
string qbXMLCountry, int qbXMLMajorVers, int qbXMLMinorVers) {
if (Session["counter"] == null) {
Session["counter"] = 0;
}
string evLogTxt="WebMethod: sendRequestXML() has been called by
QBWebconnector" + "\r\n\r\n";
evLogTxt=evLogTxt+"Parameters received:\r\n";
evLogTxt=evLogTxt+"string ticket = " + ticket + "\r\n";
evLogTxt=evLogTxt+"string strHCPResponse = " + strHCPResponse +
"\r\n";
evLogTxt=evLogTxt+"string strCompanyFileName = " +
strCompanyFileName + "\r\n";
evLogTxt=evLogTxt+"string qbXMLCountry = " + qbXMLCountry + "\r\n";
evLogTxt=evLogTxt+"int qbXMLMajorVers = " +
qbXMLMajorVers.ToString() + "\r\n";
evLogTxt=evLogTxt+"int qbXMLMinorVers = " +
qbXMLMinorVers.ToString() + "\r\n";
evLogTxt=evLogTxt+"\r\n";
ArrayList req=buildRequest();
string request="";
int total = req.Count;
count=Convert.ToInt32(Session["counter"]);
if(count<total) {
request=req[count].ToString();
evLogTxt=evLogTxt+ "sending request no = " + (count+1) + "\r\n";
Session["counter"] = ((int) Session["counter"]) + 1;
}
else{
count=0;
Session["counter"]=0;
request="";
}
evLogTxt=evLogTxt+"\r\n";
evLogTxt=evLogTxt+"Return values: " + "\r\n";
evLogTxt=evLogTxt+"string request = " + request + "\r\n";
logEvent(evLogTxt);
return request;
}
It is creating log in the end, how will i fetch the data from the QBPOS?

Make a linked list using cypher neo4j

Is there any possible way to make a linked list in cypher within one transaction ?
Iv'e tried ForEach with Match but according to neo4jClien it is not possible to set Match in ForEach.
My approach :
public static void save(List<Post> nodes)
{
var gclient = graphdb.getConnection();
var create1 = gclient.Cypher.Create("(p:Post {nodes})");
var match = gclient.Cypher.Match("((t)-[r:lastPost]->(last))");
var create3 = gclient.Cypher.Create("t-[:lastPost]->p, p-[:next]->last");
var delete = gclient.Cypher.Delete("r");
string query = create1.Query.QueryText + " " + match.Query.QueryText + " "
+ create3.Query.QueryText + " " + delete.Query.QueryText;
gclient.Cypher
.Match("(t:Tmp)")
.WithParam("nodes", nodes)
.ForEach("(newPost in {nodes} | " + query + ")")
.ExecuteWithoutResults();
}
Thanks in advance .
this should do the trick.
static Neo4jClient.Cypher.ICypherFluentQuery addnode<T>(Neo4jClient.Cypher.ICypherFluentQuery q, IList<T> items, int idx, string label)
{
string sq = string.Format("({0}:{1} {{{2}}})", "c" + idx, label, "a" + idx);
q = q.Create(sq).WithParam("a" + idx, items[idx]);
return q;
}
static Neo4jClient.Cypher.ICypherFluentQuery addlink<T>(Neo4jClient.Cypher.ICypherFluentQuery q, int idx1, int idx2)
{
string sq = string.Format("{0}-[:LINKEDTO]->{1}", "c" + idx1, "c" + idx2);
q = q.Create(sq);
return q;
}
public static void Sample<T>(List<T> items, GraphClient client)
{
Neo4jClient.Cypher.ICypherFluentQuery q = client.Connection.Cypher;
for (int i = 1; i < items.Count; i++)
{
q = addnode<T>(q, items, i-1, "MYITEM");
if(i>1)
q = addlink<T>(q, i-2, i-1);
}
q.ExecuteWithoutResults();
}

Export rich text format from TFS to Excel

I am trying to export TFS 2012 test cases to excel.
currently I was able to export the data to excel as plain text with the following code
foreach (ITestCase Testcase in testcases)
{
int j = 1;
string str1 = null;
string str2 = null;
foreach (ITestAction action in Testcase.Actions)
{
ISharedStep shared_step = null;
ISharedStepReference shared_ref = action as ISharedStepReference;
if (shared_ref != null)
{
shared_step = shared_ref.FindSharedStep();
foreach (ITestAction shr_action in shared_step.Actions)
{
var test_step = shr_action as ITestStep;
str1 = str1 + j.ToString() + "." + ((test_step.Title.ToString().Length ==0)? "<<Not Recorded>>" : test_step.Title.ToPlainText()) + System.Environment.NewLine;
str2 = str2 + j.ToString() + "." + ((test_step.ExpectedResult.ToString().Length ==0) ? "<<Not Recorded>>" : test_step.ExpectedResult.ToPlainText()) + System.Environment.NewLine;
j++;
}
}
else
{
var test_step = action as ITestStep;
str1 = str1 + j.ToString() + "." + ((test_step.Title.ToString().Length ==0) ? "<<Not Recorded>>" : test_step.Title.ToPlainText()) + System.Environment.NewLine;
str2 = str2 + j.ToString() + "." + ((test_step.ExpectedResult.ToString().Length ==0) ? "<<Not Recorded>>" : test_step.ExpectedResult.ToPlainText()) + System.Environment.NewLine;
j++;
}
}
oSheet.Cells[i, 1].Value = Testcase.Id.ToString();
oSheet.Cells[i, 2].Value = Testcase.Title.ToString();
oSheet.Cells[i, 3].Value = str1;
oSheet.Cells[i, 4].Value = str2;
ParameterizedString Description = Testcase.Description;
oSheet.Cells[i, 5].Value = Description.ToPlainText();
i++;
}
I'm using EPPlus.dll to write to the excel file.
My Question is how to export formatted text?
Why you are trying to code it?
Download "test case extractor" to excel and export all test cases to excel sheets.

How to create/read/delete cookie in blackberry widget?

How to create/read/delete cookie in blackberry widget?
have same issue but trying out these codes:
function createCookie(name, value, days) {
eraseCookie(name);
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name, "", -1);
}

Resources