Linq to DASL

jwcoleman87

Well-known member
Joined
Oct 4, 2014
Messages
124
Programming Experience
Beginner
Is this something that is out yet? Can I use it with an express version of visual studio?

I want to be able to query my outlook inbox, things are messy here at work. This could help a lot.

Can anyone point me to some resources and information about linq to DASL?
 
I think I've stumbled across those before. I got really excited and went to install the VSTO power tools and always came across installation issues. Let me give it another go and then I'll come back with exactly what trouble I'm having.

Thanks.
 
It's looking like I need to have a professional version of visual studio or better. From what I can read it works with the newer versions of office, but I can't see anything for express versions of visual studio.
 
I'll give this a try. Essentially, the customers we have escalate to a call center any issue they are having with the repair process. All of these escalations come through a unified inbox. One problem we are facing is that we have three different service centers so there is always the fact that we have to check to see if the work order belongs to our service center. I'd like to automate this process. I'll let you know what I find.
 
I've got everything installed, or so I think, but when I try the code I cannot import:
Microsoft.Office.Interop.Outlook.Extensions
Microsoft.Office.Interop.Outlook.Extensions.Linq

I think these are missing, wonder where I can find them. Searching, but if you can find it quicker it'd be appreciated.
 
Capture.JPG

The extension referred to in the tutorial doesn't appear to be there (from this link - LINQ to DASL Walkthrough - Visual Studio Tools and Anything Else I Can Think Of - Site Home - MSDN Blogs)
 
I'm not sure if I need the extensions he listed, Microsoft.Office.Interop.Outlook.Extensions.Linq

If I do I have no idea how to fix this.

The code I'm trying to write is very simple (I think) Could be doing it wrong. Throwing an error:
VB.NET:
        Dim folder = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        Dim messages = From item In folder.Items.AsQueryable(Of Outlook.MailItem)() _
                       Where item.subject.contains("Stuff") _
                       Select item
 
Last edited:
After some noobing around i got some code together that actually works (I think). But that's the problem. Now I need to figure out how to debug this.

I've tried attaching to my outlook.exe process, and it appears to work, but my breakpoints aren't hitting. Any words of advice here?

VB.NET:
    Private Sub ThisAddIn_Startup(sender As Object, e As System.EventArgs)
        Dim folder = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        Dim messages = From item As Outlook.MailItem In folder.Items _
                       Select item.Subject


        For Each item In messages
            MsgBox(item)
        Next


    End Sub

Yeah, judging by what I can gather here, it's looking like my add-in is not being hit at all. I even told it to just send a message box saying "Stuff" and it won't even do that. How do I get this working?
 
Again, more apologies, after some more noobing around i found out what I was missing:

VB.NET:
    Private Sub ThisAddIn2_Startup(sender As Object, e As System.EventArgs) [B]Handles Me.Startup[/B]
        Dim folder = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
        Dim messages = From item As Outlook.MailItem In folder.Items _
                       Select item.Subject
        For Each item In messages
            MsgBox(item)
        Next


    End Sub
 
Just wanted to post some success I've been having with Linq to DASL.

I am able to screen my inbox for messages with certain criteria (defined in the database), and then based off of the information provided from the email apply changes to the production database.

In this case, we receive emails for every quote for all repairs that move through our service center stating whether or not they are approved. Now I can apply those updates automatically to the database.

LINQ ROCKS


Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop.Outlook




Public Class TeletrackOL
    Dim parser As New EmailParser
    Dim EscalationControl As New Teletrack.EscalationControl
    Dim QuoteControl As New Teletrack.QuoteControl


    Private Sub ThisAddIn_Startup() Handles Me.Startup
    End Sub


    Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
    End Sub


    Private Sub ThisAddin_NewEmail(EntryID As String) Handles Application.NewMailEx
        Dim NewMail As MailItem = Application.Session.GetItemFromID(EntryID)
        'Validate Sender
        If EscalationControl.IsRecognizedSender(NewMail.SenderEmailAddress) Then
            'Get the SR from email
            Dim SR = GetSRFromMailItem(NewMail)
            'Get the escalation type from email
            Dim EscalationType = EscalationControl.GetEscalationType(NewMail.SenderEmailAddress)
            'Record the escalation!
            EscalationControl.RecordEscalation(SR, EntryID, EscalationType, NewMail.SenderEmailAddress, NewMail.Subject, NewMail.Body)
            'Integrate escalation with production database
            IntegrateEscalation(SR, NewMail, EscalationType)
        End If




    End Sub
    Private Sub IntegrateEscalation(SR As String, Mail As MailItem, Type As String)
        If IntegrateAuthResponse(SR, Mail, Type) Then
            'Recorded Authorization Response
        ElseIf IntegrateDispatchNotification() Then
            'Recorded Dispatch
        Else
            'No action taken
        End If
    End Sub


    'Function integrates quote authorization information with production entities
    Private Function IntegrateAuthResponse(SR As String, Mail As MailItem, Type As String) As Boolean
        If Type = "Authorization Response" Then
            If Type = "Authorization Response" Then
                If Mail.Body.Contains("Approved") Then
                    QuoteControl.SetApprovalFlag(SR, Mail.EntryID, True)
                    Return True
                ElseIf Mail.Body.Contains("Rejected") Or Mail.Subject.Contains("Pending") Then
                    QuoteControl.SetApprovalFlag(SR, Mail.EntryID, False)
                    Return True
                End If
            End If
        Else
            Return False
        End If
    End Function


    'Function integrates dispatch information with production entities
    Private Function IntegrateDispatchNotification() As Boolean
        Return False
    End Function


    Private Function GetSRFromMailItem(EscalationMail As MailItem) As String
        'Attempt to extract SR from email using the EmailParser Object
        Dim SR = (From t As EmailParser.NumericValue In parser.GetNumericValues(EscalationMail.Subject)
                  Where t.Value.ToString.Length = 8
                  Select t.Value).FirstOrDefault
        If IsNothing(SR) Then
            'Return nothing if unsuccessful
            Return Nothing
        Else
            'Return SR if successful
            Return SR
        End If
    End Function
End Class
 
Last edited:
Back
Top