Bugzilla email_in.pl reference several cc addresses - perl

When a case is created from an e-mail, I would like the list of cc present in the e-mail to be added to my default bugzilla cc list.
I was able to do it with a single cc by doing :
my ($cc_address) = Email::Address->parse($input_email->header('Cc'));
$fields('cc') = $cc_address->address;
However, what if I have several addresses, I can capture them by doing :
my (#cc_address) = Email::Address->parse($input_email->header('Cc'));
then I am not sure about how to assign the list to $fields('cc').I don't think the field does expect a list.
Does anyone have an idea ?

Not tested, but have you tried:
my (#cc_address) = Email::Address->parse($input_email->header('Cc'));
my $cc_as_string = join ",", #cc_address;
$fields('cc') = $cc_as_string

Related

BizTalk Orch/SMTP - Microsoft.XLANGs.BaseType.Content must be a message property of

This is related to my question from 2017: How Set Attachment Name to Show Properly in Outlook
This time, I have an orchestration with the following in a construct shape:
attachmentName = System.IO.Path.GetFileName(
msg_Ledger6002_File_XmlDoc
(FILE.ReceivedFileName));
msg_Email.BodyPart = new ABC.Ledger6002.Component.RawString("See attached email.");
msg_Email.AttachmentPart = msg_Ledger6002_File_XmlDoc;
// attachmentName is set earlier in orch so we could write it to EventLog for debugging
msg_Email.AttachmentPart(MIME.FileName) = attachmentName;
//msg_Email.AttachmentPart(MIME.ContentDescription) = "body";
//msg_Email.AttachmentPart(MIME.ContentTransferEncoding) = "base64";
// These are working
msg_Email(SMTP.Subject) = "Ledger6002 File";
msg_Email(SMTP.SMTPTo) = msg_Config_Email.smtpToEmail;
msg_Email(SMTP.From) = msg_Config_Email.smtpFromEmail;
msg_Email(SMTP.SMTPAuthenticate) = 0; // do not authenticate to SMTP server
// trying these two new parms below
msg_Email(SMTP.EmailBodyTextCharset) = "UTF-8";
msg_Email(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
The last line above gives me an expression shape not valid, and when I mouse over it it says identifies the error as:
Microsoft.XLANGs.BaseType.Content must be a message property of
msg_email.
Before I added the two lines under the comment "trying these two new parms below", I am getting an email with the desired attachment. The problem is that it is just called "body" and when I do "save as" from Outlook, it wants to call it "body" instead of the name of the file I dropped.
I'm using a "specify later" statically configured SendPort with PassThru for the Pipeline. I have tried a pipeline with MimeEncoder, but that caused the attachment to appear in the body. I would like to move to a dynamic pipeline, but so far I've got the static one working except for the name assigned to the file attachment.
To fix the error: "Microsoft.XLANGs.BaseType.Content must be a message property of msg_email.", I just needed to include the part name (the message is associated with a multipart message type, and I didn't include the partname):
Wrong:
msg_Email(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
Right:
msg_Email.BodyPart (Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
I'm still working on getting the email with attachment to come out correctly, but so far this post https://social.msdn.microsoft.com/Forums/en-US/988b0d91-1e5a-4f73-b30d-417d6ea9fa75/attachment-name-in-outlook-is-ok-see-on-exchange-always-named-body?forum=biztalkgeneral seems to be the best explanation.

How do I send an email via mime-mail-ses which has a proper "from" name?

The SES data type has the sesFrom field. Everywhere on the Internet I see that I should write something like "\"My Name\" <mymail#gmail.com>" in order to display My Name in the "from" field. But when I put this into the sesFrom field I get
Not sent due to SESException {seStatus = Status {statusCode = 400, statusMessage = "Bad Request"}, seCode = "InvalidParameterValue", seMessage = "Missing '<'", seRequestId = "acf8bb7d-0440-11e8-94c8-45570c829243"}
I checked sources and all seems to be fine there. How do I set the sesFrom field, so a name is displayed?
OK, got it. Instead of writing "\"My Name\" <mymail#gmail.com>" :: Address and relying on OverloadedStrings one should write
Address (Just "Ny Name") "mymail#gmail.com"
I'd say the library should parse "\"My Name\" <mymail#gmail.com>" into that address, but whatever.

How to create contact list items in a SharePoint 2013 contact list with PowerShell?

I'm trying to create contact list items in a SharePoint 2013 contact list with powershell. Creating items itself is not that hard:
$spWeb = Get-SPWeb -Identity http://sharepoint
$spList = $spWeb.GetList("/Contacts/Lists/Test")
$spListItem = $spList.AddItem()
$spListItem["Title"] = "New Item"
$spListItem.Update()
But setting the properties like street, telephone number, position, etc. drives me crazy. When creating a contact manually in the list via the Website and getting the details of it with PowerShell ($spList.GetItems()), all those properties are put together in a property called Xml.
I know I can build the xml on my own and put it in there, but this just seems not to be the right way...
So my question is: How to create a contact item with properties like street, position, etc. correctly with PowerShell?
Update:
It looks like setting properties in the xml itself does not have any impact on the item. I tried:
[XML]$a = $spListItem["Xml"];
$a.row.SetAttribute("ows_FirstName", "New Firstname")
$spListItem.Update()
But this change does not appear on the Website nor when looking at the Xml again...
Ok, finally figured it out on my own...
$spListItem["Name"] = "Name"
$spListItem["FirstName"] = "FirstName"
$spListItem["FullName"] = "FullName"
$spListItem["Email"] = "Email"
$spListItem["Company"] = "Company"
$spListItem["JobTitle"] = "JobTitle"
$spListItem["WorkPhone"] = "WorkPhone"
$spListItem["HomePhone"] = "HomePhone"
$spListItem["CellPhone"] = "CellPhone"
$spListItem["WorkFax"] = "WorkFax"
$spListItem["WorkAddress"] = "WorkAddress"
$spListItem["WorkCity"] = "WorkCity"
$spListItem["WorkState"] = "WorkState"
$spListItem["WorkZip"] = "WorkZip"
$spListItem["WorkCountry"] = "WorkCountry"
$spListItem["WebPage"] = "http://WebPage.local"
$spListItem.Update()
It is really as simple as that...
There is also as MSDN article describing how to do it in C# at https://msdn.microsoft.com/en-us/library/office/ff521580(v=office.14).aspx

how to pass current user's email address to Google Script

I have a script behind a Google spreadsheet that sends an email once certain cells of a row is completed. The script works by sending to multiple hard coded email addresses. How can I add the current user's email address as a 2nd CC? One of the CC is hard coded but the 2nd changes depending on the person updating the spreadsheet. I know how to grab the email address but how do I pass it as a variable so it actually gets CC-ed?
var currentemail = Session.getActiveUser().getEmail();
var options = {cc: 'Session.getActiveUser().getEmail(), someotheremail#domain.com'};
or
var options = {cc: 'currentemail, someotheremail#domain.com'};
GmailApp.sendEmail(email, subject, body, options);
Obviously these do not work :)
Many thanks in advance
this can be done like below :
function sendWithCc(){
var currentemail = Session.getActiveUser().getEmail();
var options = {};// create object
options['cc'] = currentemail+',someotheremail#domain.com';// add key & values (comma separated in a string)
GmailApp.sendEmail('somemail#domain.com', 'subject', 'body', options);
// I stringified 'subject' and 'body' to make that test work without defining values for it
}
Your examples should be modified as follows:
var options = {cc: Session.getActiveUser().getEmail()+', someotheremail#domain.com'};
Or
var options = {cc: currentemail+', someotheremail#domain.com'};
You cannot call a function, or reference a variable, from within a string. Instead, use the + operator to join the value of your variable (or the return value of your function call) with the string.
Note, depending on the context in which this code will be used, the script may not have permission to access the users identity regardless. See the notes under GetActiveUser() here: https://developers.google.com/apps-script/reference/base/session#getActiveUser()

Moodle Database API error : Get quiz marks for all sections of one course for one user

I am trying to get total marks obtained by a particular user, for a particular course for all the sections of that course.
The following query works and gives correct results with mysql, but not with Databse API calls
$sql = "SELECT d.section as section_id,d.name as section_name, sum(a.sumgrades) AS marks FROM mdl_quiz_attempts a, mdl_quiz b, mdl_course_modules c, mdl_course_sections d WHERE a.userid=6 AND b.course=4 AND a.quiz=b.id AND c.instance=a.quiz AND c.module=14 AND a.sumgrades>0 AND d.id=c.section GROUP BY d.section"
I tried different API calls, mainly I would want
$DB->get_records_sql($sql);
The results from API calls are meaningless. Any suggestion?
PS : This is moodle 2.2.
I just tried to do something similar, only without getting the sections. You only need the course and user id. I hope this helps you.
global $DB;
// get all attempts & grades from a user from every quiz of one course
$sql = "SELECT qa.id, qa.attempt, qa.quiz, qa.sumgrades AS grade, qa.timefinish, qa.timemodified, q.sumgrades, q.grade AS maxgrade
FROM {quiz} q, {quiz_attempts} qa
WHERE q.course=".$courseid."
AND qa.quiz = q.id
AND qa.userid = ".$userid."
AND state = 'finished'
ORDER BY qa.timefinish ASC";
$exams = $DB->get_records_sql($sql);
// calculate final grades from sum grades
$grades = array();
foreach($exams as $exam) {
$grade = new stdClass;
$grade->quiz = $exam->quiz;
$grade->attempt = $exam->attempt;
// sum to final
$grade->finalgrade = $exam->grade * ($exam->maxgrade / $exam->sumgrades);
$grade->grademax = $exam->maxgrade;
$grade->timemodified = $exam->timemodified;
array_push($grades, $grade);
}
This works in latest moodle version. Moodle 2.9. Although I am still open for better solution as this is really hacky way of getting deeper analytics about user's performance.