Reading properties from a Mailitem in Outlook outbox makes it not send - outlook

I'm writing a VSTO app for Outlook 2007 that periodically checks mails in the Outbox. I can run over the MailItems and check the .Submitted property with no adverse effects. But if I read the SentOn property than the mail in Outlook stops being italicised and no longer gets sent.
I have to go mailitem.Send() to make sure it still gets sent.
e.g.
MAPIFolder folder = Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderOutbox) as MAPIFolder;
MailItem latest = null;
foreach (object item in folder.Items)
{
MailItem mailItem = item as MailItem;
if( mailItem != null && mailItem.Submitted )
{
if (latest == null || mailItem.SentOn > latest.SentOn)
{
latest = mailItem;
}
mailItem.Send(); // have to resend as checking the sent date takes it out the queue!
}
}
Seems to be the case with most properties - but .Submitted leaves it untouched. I've not changed it in anyway so how can I inspect the mail without it going. (I should add that i've got a rule that delays the mail for 1 minute so I can get the mails as they leave)

Related

Dynamics 365 Customer Service : Email sent from one queue to another queue is getting linked to same ticket

I am facing an issue in Dynamics 365.
Let's say I have 2 queues - Queue1 & Queue2 and have enabled case creation rule on both the queues. Initially, the customer sent an email to Queue1 and converted it into the case, and I want to forward this email to Queue2.
When I forward email FROM Queue1 TO Queue2, it comes back as 'incoming' email to Dynamics through Queue2, but again gets linked to the same old case present in Queue1. I want that, it should create a new case in Queue2.
I tried a pre-create plugin also to clear regardingobject in an incoming email if the sender is a Dynamics queue and as per traces, code is clearing regardingobectid as well. However, it still gets linked to the same ticket somehow.
Is there anyone who faced the same issue and got a workaround.
Plugin code snippet - registered on Email Pre-create sync.
TargetEntity = (Entity)PluginContext.InputParameters["Target"];
var sender = TargetEntity["sender"].ToString().ToLowerInvariant();
EntityCollection senderQueue = GetQueue(sender);
if (senderQueue?.Entities != null && senderQueue.Entities.Count != 0)
{
TracingService.Trace("sender is a queue");
TracingService.Trace("updating : TargetEntity['regardingobjectid'] = null to platform");
TargetEntity["regardingobjectid"] = null;
}```
I was finally able to do it after clearing 3 attributes in the incoming email's target entity.
I have written a pre-validate sync plugin on email cleared below 3 fields :-
TargetEntity["regardingobjectid"] = null;
// this line -- parentactivityid fixed the issue.
TargetEntity["parentactivityid"] = null;
TargetEntity["trackingtoken"] = null;

How to asdd call attrs. after the call droped just like mark done button?

I am able to add call attrs using 'Genesyslab.Platform.Voice.Protocols.TServer.Requests.Userdata.RequestAttachUserData' when the call is online but how to do when the call is dropped?
I found this in WDE
void SelectDispositionCodeSetAttachedData(string dispositionCodeValueName);
//
// Summary:
// Update or add the keys of the specificed KeyValueCollection in the attached data
// of the interaction . The current list of attached data can then be retrieved
// using GetAttachedData. If the interaction media type is 'voice' or 'instant message'
// and the interaction is not released the added/updated values are immediately
// committed to T/SIP Server. If the interaction media type is 'voice' or 'instant
// message' and the interaction is released the added/updated values are sent to
// T/SIP Server as a UserEvent when the interaction is marked done (programmatic?aly
// or by Agent). If it is an eServices interaction (e-mail, chat, etc.) and the
// interaction is still handled by the agent the added/updated values are immediately
// committed to Interaction Server. After e-Services interaction is released, no
// further programmatical update is committed to Interaction Server. For all interaction
// types any attached data programmatical update applied after interaction release
// is not reflected in UI controls such as 'Case information'.
This is my code:
Genesyslab.Platform.Commons.Collections.KeyValueCollection keyValueCollectionUpDate = new Genesyslab.Platform.Commons.Collections.KeyValueCollection();
keyValueCollectionUpDate.Add("Business Result", "Platform: Business Result");
keyValueCollectionUpDate.Add("StrAttribute1", "AttachedData.Business Result"); RequestAttachUserData requestAttachUserData= RequestAttachUserData.Create("7012", GetConnectionID(ExtractedArtributes[1][0].Value.ToString()), keyValueCollectionUpDate); IMessage respondingEvent2=tserverProtocol.Request(requestAttachUserData);
Need to add call attts after the call is dropped
You can't update attached data when the call is dropped.
I do a workaround by using WDE itself to attach data when agent clicks 'mark done' in WDE custom command.
The way to attach data to voice calls after disconnect, is to send a UserEvent. This does require the AfterCallWork state to be enabled in your environment. You have already mentioned understanding how to insert Commands into the Command Chain. This example Execute function of a command can be inserted into the "BundleClose" Command Chain, prior to the "Close" Command.
This sample is in VB, apologies, but I guess you can easily convert to c#.
Public Function Execute(ByVal parameters As IDictionary(Of String, Object), ByVal progress As IProgressUpdater) As Boolean Implements IElementOfCommand.Execute
' To go to the main thread
If Application.Current.Dispatcher IsNot Nothing AndAlso Not Application.Current.Dispatcher.CheckAccess() Then
Dim result As Object = Application.Current.Dispatcher.Invoke(DispatcherPriority.Send, New ExecuteDelegate(AddressOf Execute), parameters, progress)
Return CBool(result)
Else
Dim interactionsBundle As IInteractionsBundle = Nothing
Dim interaction As IInteraction = Nothing
interactionsBundle = parameters("CommandParameter")
interaction = interactionsBundle.MainInteraction
Dim channel As Enterprise.Model.Channel.IClientChannel = interaction.EntrepriseInteractionCurrent.ActiveChannel 'agent.Channel
Dim protocol As IProtocol = channel.Protocol
Dim kvp As Platform.Commons.Collections.KeyValueCollection = New Platform.Commons.Collections.KeyValueCollection()
kvp.Add("keyname", "keyvalue")
Dim userevent As Platform.Voice.Protocols.TServer.CommonProperties = Platform.Voice.Protocols.TServer.CommonProperties.Create()
userevent.UserData = kvp
Dim connID As Platform.Voice.Protocols.ConnectionId = Nothing
Dim interactionVoice as IInteractionVoice = TryCast(interaction, IInteractionVoice)
If interactionVoice IsNot Nothing Then
userevent.UserEvent = Platform.Voice.Protocols.TServer.Events.EventUserEvent.MessageId
connID = New Platform.Voice.Protocols.ConnectionId(interactionVoice.TConnectionId)
Dim strDN As String = Nothing
'ensure the correct DN is passed when attaching reason codes, in case agent is logged into multiple DNs
Dim devices() As Enterprise.Model.Device.IDevice = interactionVoice.Device
Dim device As Enterprise.Core.DN = devices(0)
strDN = device.Name
userevent.ThisDN = strDN
userevent.ConnID = connID
Dim req = Platform.Voice.Protocols.TServer.Requests.Special.RequestSendEvent.Create()
req.UserEvent = userevent
'send request
protocol.Send(req)
End If
End If
End Function

MAPI Control Multiple attachments

I am trying to send an email with multiple attachments using the VB6 MAPIMessages control.
1) I am able to use this control to send a single attachment but it displays an error saying "Attachment not found", if I try to send more than one file.
2) I also need to suppress the warning message when I try to send an email
Any ideas?
Here's the code:
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID
MAPIMessages1.Compose
MAPIMessages1.RecipDisplayName = "abbid_siddiqui#hotmail.com"
MAPIMessages1.MsgSubject = "MAPI subject with attachments"
MAPIMessages1.MsgNoteText = "This is atest"
MAPIMessages1.AttachmentIndex = 0
MAPIMessages1.AttachmentName = "test.csv"
MAPIMessages1.AttachmentPathName = "C:\test.csv"
MAPIMessages1.AttachmentIndex = 1
MAPIMessages1.AttachmentName = "holidays_2013.xls"
MAPIMessages1.AttachmentPathName = "E:\holidays_2013.xls"
MAPIMessages1.ResolveName
'Send the e-mail message to the Recipient
MAPIMessages1.Send
Try setting the AttachmentPosition property to the same value as the AttachmentIndex

How to handle Reminder that are old and new for windows phone

say, this is the way to create reminder:
Reminder reminder = new Reminder(name);
reminder.Title = titleTextBox.Text;
reminder.Content = contentTextBox.Text;
reminder.BeginTime = beginTime;
reminder.ExpirationTime = expirationTime;
reminder.RecurrenceType = recurrence;
reminder.NavigationUri = navigationUri;
// Register the reminder with the system.
ScheduledActionService.Add(reminder);
I can not see the result as I use emulator and I have these questions:
1) If I create a reminder today 25/Jul : Begin time 25-jul and ExpirationTime : 25-jul, after 25-jul, will the reminder created on 25-jul will still be in the system or scheduler?
2) If the expirationTime is 28-Jul, will it shows the BeginTime when this reminder got activated on 28-jul?
3) How to I retrieve all the reminders have not be activated.
Thanks
--- Updated :
var reminders = ScheduledActionService.GetActions (ScheduledAction)();
.Where(a => a.IsScheduled);
1) Yes, it will be there. Reminders associated with an application are still available, even if those are dismissed by the user.
2) The BeginTime will be set according to the class property that is set by the application, not when the reminder was activated.
3) You can retrieve all reminders registered for your application through:
var n = ScheduledActionService.GetActions<Reminder>();
foreach (Reminder r in n)
// Action here
You can check the IsScheduled property to make sure that the reminder is scheduled to be triggered or is already out of the queue.

Get EntryID of new mail

We made a script that automatically opens the Microsoft Outlook new mail window. Some things have to be filled in already. This works so far:
Set Arguments = WScript.Arguments
If Arguments.Count > 4 Then
Set Outlook = CreateObject("Outlook.Application")
Set BodyObject = CreateObject("Scripting.FileSystemObject")
Set Mail = Outlook.CreateItem(0)
Mail.To = Arguments(0)
Mail.CC = Arguments(1)
Mail.BCC = Arguments(2)
Mail.Subject = Arguments(3)
Set BodyFile = BodyObject.OpenTextFile(Arguments(4))
Mail.Body = BodyFile.ReadAll
BodyFile.Close
For Counter = 5 to (Arguments.Count - 1)
Mail.Attachments.Add Arguments(Counter)
Next
Mail.Display
End If
But know we want to know if that mail gets sent by the user and we also want to know the EntryID of that mail, so we can look it up later.
Now Mail.Display doesn't return anything and the program just ends. It does not wait until the window gets closed. So after Mail.Display, there should be something like: Mail.Wait, or a Mail send event so we can get the EntryID.
Could someone help us out?
Thanks in advance,
Gillis and Emiel
I just found a probable solution from here:
You need to wait and get the EntryID
value after the item has been
delivered from the Outbox. To do this,
subscribe to the Folder.Items.ItemAdd
event on the Sent Items folder. That
event passes the newly added -- i.e.
newly sent -- item as its argument.
The item must exist first in Outlook to have an EntryID value, use the Save Property and fetch its EntryID right after
Mail.Save
strEntryID = Mail.EntryID
I've got a sample written in VBA for saving notes from Access form to Outlook
Dim outobj As Outlook.Application
Dim outappt As Outlook.NoteItem
Set outobj = CreateObject("outlook.application")
Set outappt = outobj.CreateItem(olNoteItem)
With outappt
If Not IsNull(Me!strBody) Then .Body = Me!strBody
.Save
Me!strEID = .EntryID
End With

Resources