Is there a way to programmatically grab a list of meeting attendees from Outlook? - perl

I am trying to grab a list of meeting attendees from Outlook 2003. I am open to using any language that would be appropriate. Scripting languages are preferable. Any suggestions?

The information is exposed through the outlook COM interface so any language that can talk COM would work fine.
I once wrote a piece of code that did just this (and some more), and you can see the source yourself.
If you can't be bothered to look through that code, in a nutshell you do:
// Also, don't forget to add a project reference to the outlook COM object
using Microsoft.Office.Interop.Outlook;
...
var outlookNS = OutlookApp.GetNamespace("MAPI");
var calendar = outlookNS.GetDefaultFolder(OlDefaultFolders.olFolderCalendar);
foreach (AppointmentItem item in calendar.Items)
{
// Mandatory attendees (in the "To:" field)
foreach (var attendee in item.Recipents)
Console.WriteLine("Attendee {0}", attendee);
// Optional Attendees (in the "CC:" field)
foreach (var attendee in item.OptionalAttendees)
Console.WriteLine("Attendee {0}", attendee);
}

In perl you would use Win32::OLE.
See for examle this link and of course the documentation that comes with that module.
You should also be able to simply rewrite the VB code given above to perl using Win32::OLE.
And also see this other question.

Related

MailKit - How can bodybuilder help create a complex email body with many images interspersed with text?

For example, what if you need to create an email body like this:
Text ...
Image ...
Text ...
Image ...
Text
Here is one of the examples that works for one text and one image:
var builder = new BodyBuilder ();
var pathImage = Path.Combine (Misc.GetPathOfExecutingAssembly (), "Image.png");
var image = builder.LinkedResources.Add (pathLogoFile);
image.ContentId = MimeUtils.GenerateMessageId ();
builder.HtmlBody = string.Format (#"<p>Hey!</p><img src=""cid:{0}"">", image.ContentId);
message.Body = builder.ToMessageBody ();
Can we do something like builder.HtmlBody += to just keep adding more and more texts and images?
The BodyBuilder class is designed to constructing typically message structures, not the type of thing you are doing.
You will need to construct your message manually, not using BodyBuilder.
After quite a bit of trial/error/testing, I discovered that you can indeed keep adding text and images to the HtmlBody object, as my question speculated, by using builder.HtmlBody +=
In response to the increasingly widespread use of TLS instead of SSL, and therefore the need to abandon the use of Microsoft's obsolete SmtpClient component, I have developed a comprehensive emailing test component, in Visual Basic, using the wonderful MailKit from JStedfast.
As my question suggested, I wanted to give my users the ability to compose a handsome email body using text interspersed with images as needed. If any VB developers would like to benefit from this work, just let me know.
#jstedfast - I just saw your answer after posting this. For my production version, I need to add images from a blob field in a SQLServer table. I intend to use the manual method, as you stated, to do that. But for images I was loading into my sample program, I was able to make a fairly complex email body using src=file for each image, and adding them with builder.HtmlBody +=

Export Standard/Extended User Greetings (Exchange 2016) - For Use In XMedius AVST

In an earlier post on June 18, 2018 (my birthday BTW), a user asked "Hopefully a simple question - at one time I know when user's recorded their personal greetings for UM voicemail in o365 (regular greeting and/or extended absence greeting) these were stored in their Exchange inbox using a special item type (i.e. "IPM.Configuration.Um.CustomGreetings.External"). However setting up my test o365 setup, getting UM configured and all that, after recording my personal greeting and going through each item starting from the root of my inbox, (some 900+ items - lots of odd stuff in there) - I don't see anything like this any more. Lots of log, activity items, some messages but nothing about greetings. Extracting everything that could cast to an email type to a folder I went through each one - nothing promising. anyone have any clues where the custom greetings for users UM (not auto attendant recordings - that's a different beast) has gone off to and how to get to it?" After reading through the answers as well as the code that was provided by Jeff Lindborg, I thought that I was getting somewhere. With a lot of trial and error, I was finally able to get the EWS-FAI module installed as well as the Exchange Web Services API. Unfortunately, when it came to running the provided code, this is where I am stumped. I'm not a developer or 'coder' in any form, but I'm always looking for effective and efficient methods to do my work. With that said, I'm trying to run this on a Win10 workstation, but can't seem to figure out which program this needs to run within. I've tried Powershell, but that doesn't work. I have access to the necessary accounts for mailbox impersonation as well as any other permissions needed. I've provided the code that was originally supplied for review. Any additional help would be greatly appreciated.
Code
ExchangeService _service;
_service = new ExchangeService(ExchangeVersion.Exchange2016); // Exchange2013_SP1);
_service.Credentials = new WebCredentials("user#domain", "myPw");
_service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
//select the user you're fetching greetings for
_service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "user#domain");
//get the root folder for the current account
var oParamList = new List<FolderId> {WellKnownFolderName.Root};
var oTemp = _service.BindToFolders(oParamList, PropertySet.FirstClassProperties);
var oRoot = oTemp.First().Folder;
var oView = new ItemView(50)
{
PropertySet = new PropertySet(BasePropertySet.FirstClassProperties),
Traversal = ItemTraversal.Associated
};
SearchFilter oGreetingFilter = new SearchFilter.ContainsSubstring(ItemSchema.ItemClass,
"IPM.Configuration.Um.CustomGreetings", ContainmentMode.Substring, ComparisonMode.IgnoreCase);
var oResults = _service.FindItems(oRoot.Id, oGreetingFilter, oView);
//fetch the binary for the greetings as values
var oPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
var oRoamingBinary = new ExtendedPropertyDefinition(31753, MapiPropertyType.Binary);
oPropSet.Add(oRoamingBinary);
_service.LoadPropertiesForItems(oResults, oPropSet);
var strFileName = "";
foreach (var oItem in oResults.Items)
{
if (oItem.ItemClass.Equals("IPM.Configuration.Um.CustomGreetings.External",
StringComparison.InvariantCultureIgnoreCase))
strFileName = "jlindborg_Standard.wav";
if (oItem.ItemClass.Equals("IPM.Configuration.Um.CustomGreetings.Oof",
StringComparison.InvariantCultureIgnoreCase))
strFileName = "jlindborg_Extended.wav";
File.WriteAllBytes("d:\\" + strFileName, (byte[]) oItem.ExtendedProperties.First().Value);
}
}
The code you posted is c# so you would need to use Visual Studio to create a C# application add a reference to the EWS Managed API and compile that for it to work (you'll need to engage a developer or learn some basic coding).
EWS-FAI is a powershell module it should be able to return that item and you should be able to write that to a file eg something like
$MailboxName = "mailbox#domain.com"
$Item = Get-FAIItem -MailboxName $MailboxName -ConfigItemName Um.CustomGreetings.External -Folder Inbox -ReturnConfigObject
[System.IO.File]::WriteAllBytes(("C:\temp\" + $MailboxName + ".wav"),$Item.BinaryData)

Generate new email from a custom outlook form

I have built a form that stores certain contact data on it. I want to include a couple of buttons/functions to keep the user in the form as much as possible versus switching between Outlook components (calendar, mail, etc.).
In this case the user can swap email addresses from separate ListBoxes and when they hit the button it will use the emails within one of them. Using VBS because I'm dealing with custom Outlook forms.
Sub GenerateButton_Click()
'Generates Email with all of the CCs
'Variables
Set FormPage = Item.GetInspector.ModifiedFormPages("Commands")
Set DoSend = FormPage.Controls("DoSendListBox")
mailList = ""
'Generate Email List
For x = 0 to (DoSend.ListCount - 1)
mailList = mailList & DoSend.List(x) & ";"
Next
'Compose Email
Set msg = Application.CreateItem(olMailItem)
msg.Subject = "Hello World!"
msg.To = mailList
End Sub
What Happens
- it compiles
- nothing happens on click
Research
- online forums usually in VBA
- relevant articles use outside connection rather than from within outlook
SOLVED
Note: Click on the "script" option and select the object item. From the new window you can navigate through the classes and from this I was able to find MailItem. You can see all of the methods/properties on the right hand pane.
It Turns out the correct syntax was:
Set msg = Application.CreateItem(MailItem)
msg.Display

Get Word's window handle to use with WPF windows

I have a number of WPF dialogs in my Word Add-In. For one of them (and only one, strangely), it is sometimes not focused when opened. I believe I need to set its parent.
I know there is a way to set the owner of a WPF window to a HWND, but is there any way to get a HWND in Word 2010? I found this HWND property but it is Word 2013 and later only. Is there any other way to get Word's HWND, other than using GetForegroundWindow() which does not guarantee the handle for the window I actually want (or any other similar kludge)?
I found something helpful in Get specific window handle using Office interop. But all those answers are based on getting the handle for a window you're newly creating. I modified it somewhat to get an existing window, and stuffed it into a utility method.
doc is the current document.
using System.Windows.Interop;
using System.Diagnostics;
public void SetOwner(System.Windows.Window pd)
{
var wordProcs = Process.GetProcessesByName("winword").ToList();
// in read-only mode, this would be e.g. "1.docx [Read-Only] - Microsoft Word"
var procs = wordProcs.Where(x =>
x.MainWindowTitle.StartsWith(Path.GetFileName(doc.FullName))
&&
x.MainWindowTitle.EndsWith("- Microsoft Word"));
if (procs.Count() >= 1)
{
// would prefer Word 2013's Window.HWND property for this
var handle = procs.First().MainWindowHandle;
WindowInteropHelper wih = new WindowInteropHelper(pd);
wih.Owner = handle;
}
}
Unfortunately it doesn't seem to be possible to account for multiple windows with the same document name (in different folders), because the number of processes is never greater than 1. But I think that's an acceptable limitation.

Prevent Gmail from creating links for URLs and email addresses

Problem is Gmail automatically creates hyperlinks for all website URLs and email addresses. I do not want to create a link.
var mailClient = new SmtpClient();
var netMail = new MailMessage();
msg = "I do not want www.google.com as a link at recipient end. <br/>";
msg += "I want my email addrress myemail#myudomain.com as html without a link";
var cr = new NetworkCredential("########", "###########");
netMail.From = new MailAddress("#########m####.###", "######");
netMail.To.Add(new MailAddress("abc#xyz.com"));
netMail.Subject = "Test Mail";
netMail.IsBodyHtml = true;
netMail.Body = msg;
mailClient.Host = "xyz.com";
mailClient.Port = 25;
mailClient.EnableSsl = false;
mailClient.Credentials = cr;
mailClient.Send(netMail);
Any solution?
I had a same issue and found out if you use email like this;
<a rel="nofollow" style='text-decoration:none; color:#333'>test#mydomain.com</a>
email providers does not tend to follow email as a link.
Hope this helps.
There's no way to stop creating URLs, because its automatically checked by the email provider that whether the text is a valid URL.
Only way to overcome this is, deceiving the parser. Just put spaces, HTML tags, whatever in such a way that the parser can't identify like URL etc.
Here are a few code examples:
http:<span>//foolishedsiteparser.com</span>
_http://www.parsersmashed.com
noonesemail<x>#</x>linkdead.com>
And the result is the following:
http://foolishedsiteparser.com
_http://www.parsersmashed.com
noonesemail#linkdead.com
I was able to get around this issue just by adding <a style="color: #000000">link text</a> (notice there is no href).
I haven't tried using attributes besides style but I would imagine you could. The email system that I use (Blackbaud NetCommunity) will strip out a plain <a> tag, so I had to have at least one attribute.
Taking a cue from perilbrain's answer, I implemented the following regex that I use for this:
var unlink = function (val) {
return val.replace(/([#\.:])/g, '<span>$1</span>');
};
Note that this function replaces globally on whatever is passed in -- it would probably be too aggressive for blocks of natural text as in the OP's example, but often templates are parameterized and this works great when you can just pass it a url or email (I actually implemented it as a template helper function so that it does exactly that).
The function converts the following inputs:
john.doe#gmail.com
http://johndoe.com
into this:
john<span>.</span>doe<span>#</span>gmail<span>.</span>com
http<span>:</span>//johndoe<span>.</span>com
Note that I tried a fake short tag like <x> as shown in the accepted answer and found that GMail "intelligently" replaced it with <u> tags, which I assume is a feature, but was not desirable. In my testing, <span> tags prevent linking with no visual side-effects.
None of the solutions listed here seem to work any more. I experimented a little with the idea of non-printable Unicode characters and found this sequence to work:
<span>foo‌.‌bar‌.‌com</span>
Where ‌ is the ZERO WIDTH NON-JOINER character.
Nailed it!
This does not prevent emails from being turned into links, but it allows you to set the font color and remove the underline of that link.
It works in all email clients I tested in on litmus.com - including Outlook 2010, 2013, 2016 (also on Windows), Outlook.com, iPhone 6s, iPad, gmail web interface and Apple Mail 8, 9
Variation 1:
A link which does not react when clicked upon
bjorn#rosell.dk
Variation 2:
A mailto-link. Works in almost all clients. Outlook.com does however style it blue and with underline.
bjorn#rosell.dk
I have one unmentioned solution for textual emails: Use similar unicode characters. For example one dot leader (U+2024) instead of dot. Compare, how looks Běhej.com and Běhej․com (the first one is with regular dot).
I had a dot com in the title of my confirmation message.
Inspired by #perilbrain, I revolved my problem like this
domain.com => domain<span>.</span>
php
$titre = str_replace(".", "<span>.</span>", $titre);
simple !
For now simple wrapping by <span> is not working, I suggest replace # by its html-entity alternative
function disable_email_link($email) {
//encoder https://mothereff.in/html-entities
$email = str_replace('#', '#', $email);
$email = str_replace('.', '<span>.</span>', $email);
return $email;
}
Also if your email contains phone numbers you can escape it by disable_tel_link function:
function wrap_span_letters($string) {
$res = "";
$length = strlen($string);
for ($i = 0; $i < $length; $i++) {
$res .= "<span>$string[$i]</span>";
}
return $res;
}
function disable_tel_link($phone) {
return wrap_span_letters($phone);
}
Eventhough this is a old thread i want to help people who might get here. I found that adding a span inside the link makes google not see it as a link see below:
www.<span></span>link.dk
i had the same problem so after few mins found out how to fix it.
the thing is if you target the element directly it won't work because gmail will automatically add aa "a" tag in there so you have to go one step farther and declare a class for that "a" tag. in my case the email was in a "" tag which i found it easier to work with. so what i did was create a class like this:
.email_contact a {color:#ffffff!important; text-decoration: none!important;}
there is no "a" tag in my code but since gmail will add it automatically then you should catch it there. now you just have to use that class where ever you put your email add such as "span" or "div" and boom! fixed.
While not the ideal solution, it may be an option for some. As of 3/12/2020, If you disable Multipart and send plain text only emails, you'll get the following hyperlinked results. Results appear to be the same whether at the beginning of a new line/sentence or mid sentence.
Suppose your display url is "abcdUrl.com"
To prevent gmail from showing as a link, wrap it in an anchor tag
<a href="" style="text-decoration:none;color:#333;">
abcdUrl.com
</a>
This works well in gmail.