Is there a way to generate emails on Exchange with past sent/received dates - email

We have a component that grabs emails/meetings from Exchange (Online, 2013, 2010) and we'd like to create email distribution in the past timeframe e.g. 6 month for testing purposes.
In order to achieve this we definitely need emails that have received/Sent dates to be in the past, not started from current (from generation moment) time when we started email generation.
We looked at EWS API - it does not support changing of the dates for created (generated) emails.
What other options exists?

You can create an Email with EWS that looks like it was received in the past if you change the Extended properties on the message eg
EmailMessage OldMessage = new EmailMessage(service);
OldMessage.ToRecipients.Add("user#domain.com");
OldMessage.Sender= new EmailAddress("bob#domain.com");
OldMessage.From = new EmailAddress("bob#domain.com");
OldMessage.Subject = "This is an old message";
OldMessage.Body = new MessageBody("test");
ExtendedPropertyDefinition PR_Flags = new ExtendedPropertyDefinition(3591,MapiPropertyType.Integer);
OldMessage.SetExtendedProperty(PR_Flags,1);
ExtendedPropertyDefinition PR_CLIENT_SUBMIT_TIME = new ExtendedPropertyDefinition(0x0039,MapiPropertyType.SystemTime);
ExtendedPropertyDefinition PR_MESSAGE_DELIVERY_TIME = new ExtendedPropertyDefinition(0x0E06,MapiPropertyType.SystemTime);
OldMessage.SetExtendedProperty(PR_CLIENT_SUBMIT_TIME,DateTime.Now.AddMonths(-6));
OldMessage.SetExtendedProperty(PR_MESSAGE_DELIVERY_TIME,DateTime.Now.AddMonths(-6));
OldMessage.Save(WellKnownFolderName.Inbox);
You can also just import a message using the MimeContent that would do the same thing eg https://msdn.microsoft.com/en-us/library/office/dn672319(v=exchg.150).aspx
Cheers
Glen

Related

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

Alfresco - Using email notification template not working properly

I'm using out-of-the-box Alfresco 4.2.f, without customizations, and i'm trying to set the email notification whether a new document in added in a certain folder.
So i've added a rule to the folder and i've set as Perform Action "Send email" using as template "notify_user_email_it.html.ftl".
If i insert a document, i don't receive the email and here is the error in the log:
Expression person is undefined on line 38, column 57 in workspace://SpacesStore/55088e2c-05ac-4264-8396-ee6f3c7021ad.
The problematic instruction:
----------
==> ${person.properties.firstName} [on line 38, column 55 in workspace://SpacesStore/55088e2c-05ac-4264-8396-ee6f3c7021ad]
----------
If i remove from the template the string ${person.properties.firstName} then the rule works properly but the mail i receive is not as expected, all the interesting informations are shown as in the original FTL. Attached the email received to understand better.
Really strange since i've not customized anything, maybe this is a BUG but i didn't find anything on JIRA...
Someone has the same behaviour? Possible work-arounds?
Thanks in advance!
According to this JIRA, it's not really a bug it just doesn't work for the admin user.
Have you tried it with a normal user?
--- Update ---
Maybe cause it's bug or an unimplemented feature something like the following to fix it in the template:
<#if person??>
.... set your person properties first & lastname
<#else>
.... is sure to be admin, so set the admin
</#if>
You have to pass the parameters to emails templates
you may try with this example
var template = "Data Dictionary/Email Templates/Workflow Notification/<<Your File>>.html.ftl";
var mail = actions.create("mail");
mail.parameters.to = "xyx#gmail.com";
mail.parameters.subject="Hello";
mail.parameters.text="blablabla";
mail.parameters.template = companyhome.childByNamePath(template);
var templateArgs = new Array();
templateArgs['workflowTitle'] = "789789";
templateArgs['workflowDescription'] = "879789";
templateArgs['workflowId'] = "879789";
var templateModel = new Array();
templateModel['args'] = templateArgs;
mail.parameters.template_model = templateModel;
mail.execute(bpm_package);
then you can get parameters using ${args.workflowTitle} in your Email template ftl file

QBO Queries and SpecifyOperatorOption

I'm trying to query QBO for, among other entities, Accounts, and am running into a couple of issues. I'm using the .Net Dev Kit v 2.1.10.0 (I used NuGet to update to the latest version) and when I use the following technique:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
(i.e. just create a new AccountQuery of the appropriate type and call ExecuteQuery) I get an error. It seems that the request XML is not created properly, I just see one line in the XML file. I then looked at the online docs and tried to emulate the code there:
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
cquery.CreateTime = DateTime.Now.Date.AddDays(-20);
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.AFTER);
cquery.CreateTime = DateTime.Now.Date;
cquery.SpecifyOperatorOption(Intuit.Ipp.Data.Qbo.FilterProperty.CreateTime,
Intuit.Ipp.Data.Qbo.FilterOperatorType.BEFORE);
// Specify a Request validator
Intuit.Ipp.Data.Qbo.AccountQuery cquery = new Intuit.Ipp.Data.Qbo.AccountQuery();
IEnumerable<Intuit.Ipp.Data.Qbo.Account> qboAccounts = cquery.ExecuteQuery<Intuit.Ipp.Data.Qbo.Account>(context);
unfortunately, VS 2010 insists that AccountQuery doesn't contain a definition for SpecifyOperatorOption and there is no extension method by that name. So I'm stuck.
Any ideas how to resolve this would be appreciated.

Trying to change owner of account on CRM 4.0 using a plugin

I am creating a plugin for Microsoft Dynamics CRM 4 that will change the owner of the account entity according to the value of another lookup field. Now I have managed to get the GUID of the user that will be acting as the 'Owner' of the account. So far so good.
The problem arises when I try to change the owner. I am trying to use AssignRequest but it is not working. When I try to execute the request I get a SoapException on the C# Debugger, and the webservice outputs a dialog stating:
"The requested record was not found or you do not have sufficient permissions to view it"
Below is the code I am using:
TargetOwnedAccount target = new TargetOwnedAccount();
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;
assignee.PrincipalId = context.InitiatingUserId;
target.EntityId = ownerGuid; //this is the GUID I am retrieving from the other lookup field
AssignRequest assign = new AssignRequest();
assign.Assignee = assignee;
assign.Target = target;
AssignResponse res = (AssignResponse)crmService.Execute(assign); //this is where i get the exception
I hope I haven't missed anything.
Any help would be much appreciated :)
Thanks
Ok i managed to solve this finally. It had been staring directly at my face :P
I was entering the wrong ID's at the wrong place. I needed to set the 'assignee.PrincipalId' to the 'ownerGuid' and then set the 'target.EntityId' to the current account id. The new code is as follows:
TargetOwnedAccount target = new TargetOwnedAccount();
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;
assignee.PrincipalId = ownerGuid; //this is the GUID I am retrieving from the other lookup field
target.EntityId = ((Key)entity.Properties["accountid"]).Value;
AssignRequest assign = new AssignRequest();
assign.Assignee = assignee;
assign.Target = target;
AssignResponse res = (AssignResponse)crmService.Execute(assign);
Cant believe i spent 8 hours yesterday looking at it and then today I realised immediately :P