Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

Previous Next

Mailin Monitoring agent

I wrote a ticketing system in which you could send it an eMail and it turns it into an IT Helpdesk ticket.

Its an agent set to trigger if there are new documents. It only permitted mail sent from our domain, and can respond to various requests. Its a bit long-winded, but you'll get the idea. bear in mind the database has to be mentioned in your NAB as a mail-in DB.

Option Public
Use "ITServiceDesk"
Use "HotSpotRoutines"
Dim Session As NotesSession
Dim NABDb As NotesDatabase
Dim MailinView As NotesView
Dim TicketView As NotesView
Dim NABView As NotesView
Dim NABSView As NotesView
Dim SPView As NotesView
Dim PSPView As NotesView
Dim NABDoc As NotesDocument
Dim NABSdoc As NotesDocument
Dim MailIndoc As notesdocument
Dim TempDoc As NotesDocument
Dim TicketDoc As NotesDocument
Dim MailOutDoc As NotesDocument
Dim SPDoc As NotesDocument

Dim MailInTo As NotesItem
Dim richStyle As NotesRichTextStyle
Dim RtItem As NotesRichTextItem
Dim MailInRtItem As NotesRichTextItem
Dim TicketRtItem As NotesRichTextItem
Dim PRTItem As NotesRichTextItem
Dim dc As NotesDocumentCollection
Dim IndusUser As NotesName
Dim CurrentServer As NotesName
Dim UserMailServer As NotesName
Dim ITDBServer As NotesName
Dim Subject As String
Dim Success As Variant
Dim Desc As String
Dim BodyString As String
Dim SomethingToMail As Integer
Dim EMailUpdate As Variant





Sub Initialize

Dim db As NotesDatabase
Dim PDoc As NotesDocument

Set Session = New NotesSession
Set db = session.currentdatabase
Set Currentserver = New NotesName(db.server)
Set MailinView = db.Getview("(NewMail)")
Set TicketView = db.GetView("(ByTicketNum)")
Set SPView = db.GetView("Server Profiles")
Set PSPView = db.GetView("(ProfilesByITDBServer)")

' We assume that we're going to work with the Name & Address book on
' the same server as the IT ServiceDesk database. We need the address book
' so we can verify the user's E-Mail address

Set NABdb = New NotesDatabase(db.Server,"Names.nsf")
Set NABView = NABDb.GetView("($Users)")

Set Mailindoc = MailinView.GetFirstDocument

While Not MailInDoc Is Nothing

' Now for the myriad of tests to be sure we really want to respond to this memo....
If Not MailInDoc.HasItem("$AutoForward") _
And MailinDoc.HasItem("DeliveredDate") _
And Not MailInDoc.HasItem("FailureReason") Then

Set MailInRtItem = MailInDoc.GetFirstItem("Body")

' Let's load up the beginning of the outgoing message document.

SomethingToMail = 0

Set mailoutdoc = New NotesDocument(db)
MailOutDoc.Form = "Memo"
Subject = MailInDoc.Subject(0)

' Get the correct server location of the IT ServiceDesk replica for the user on this ticket.

MailOutDoc.SendTo = MailInDoc.From(0)
Set NABDoc = NABView.GetDocumentByKey(MailInDoc.From(0))

If NABDoc Is Nothing Then
ParseSender = False
MailOutDoc.INetPrincipal = "ITServiceDesk@Indus.com"
MailOutDoc.Principal = "ITServiceDesk"
Else
ParseSender = True
Set IndusUser = New notesname (NABDoc.Owner(0))
Set UserMailServer = New NotesName(NABDoc.MailServer(0))
Set SPDoc = PSPView.GetDocumentByKey(UserMailServer.Abbreviated)
If SPDoc Is Nothing Then
MailOutDoc.INetPrincipal = "ITServiceDesk@Indus.com"
MailOutDoc.Principal = "ITServiceDesk"
Else
Set ITDBServer = New NotesName(SPDoc.Server(0))
MailOutDoc.InetPrincipal = SPDoc.MailInName(0)
MailOutDoc.Principal = SPDoc.MailInName(0)
End If
End If

' Gussy it up a bit with a Bold Blue announcement.
Set richStyle = session.CreateRichTextStyle
Set rtitem = New NotesRichTextItem(MailOutDoc, "Body")
Call MemoHeadLine (RtItem,RichStyle)

' Process Help command or let the forgien mail user know how to do this properly.

If ParseSender = False Or Trim(Lcase(Subject)) = "help" Then
SomethingToMail = 1
MailOutDoc.Subject = "[" & Db.Title & "] assistance"
If ParseSender = False Then
Call RtItem.AppendText(" * * * Your E-Mail address is not a valid Indus E-Mail addresses * * *")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("The automated Indus IT ServiceDesk system does not permit you interact with IT via a Non-Indus, Non notes E-Mail account. You must interact with the system from a valid Indus Notes account using your notes client or from your mail database through Indus-web")
Call RtItem.AddNewLine(2)
End If
richstyle.Bold = True
Call rtitem.AppendStyle(richstyle)
richstyle.Fontsize = 12
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("Initiating a new call:")
richstyle.Bold = False
Call rtitem.AppendStyle(richstyle)
richstyle.Fontsize = 10
Call rtitem.AppendStyle(richstyle)
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("To start a new call, simply send a mail message to your appropriate regional IT Service Desk E-Mail address (Listed at the bottom of this message). In the subject field, enter a short summary of the nature of your problem")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("In the body of the message, place any detailed information, attachments, etc. (Please keep attachments below 5 megs)")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("A new call ticket will be generated. You will then be sent a confirmation message with the ticket number when the ticket is assigned a staff member.")
richstyle.Bold = True
Call rtitem.appendstyle(richstyle)
Call RtItem.AppendText("Keep this message handy for any future correspondence as you will need the contents of the subject message")
richstyle.Bold = False
Call rtitem.appendstyle(richstyle)
Call RtItem.AddNewLine(2)
richstyle.Bold = True
Call rtitem.AppendStyle(richstyle)
richstyle.Fontsize = 12
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("Responding to an existing call:")
richstyle.Bold = False
Call rtitem.AppendStyle(richstyle)
richstyle.Fontsize = 10
Call rtitem.AppendStyle(richstyle)
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("If you are responding to an existing ticket, you should place the following in the Subject field;")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText(" Re: Ticket# XXXX-XXXXX")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("where XXXX-XXXXX is the number of your ticket.")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("A Hint: If you save your initial responce from the IT ServiceDesk system, just copy the subject line and paste it into any response message you send. If you wish to create a new ticket, do not place the string; 'Ticket#' anywhere in the subject line in any permutation of upper and lower case as that's what this agent keys off of. Also, the string; 'Ticket #' should be followed by the number of the ticket with nothing else after it.")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("When replying to messages from this system, please refrain from using 'Reply with history'. The ticket likely already has that history in it and this just duplicates the information. Also, please do not include any attachments in any responses to a ticket. The system will not store them. If you need to do this, you should use your notes client or a web browser to interact with the IT ServiceDesk system directly")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("When your ticket is assigned, you will be provided with an additional mail message that includes a button that can be used from the Notes client, and a URL that can be used from a web browser (Internet explorer/Netscape).It's actually preferable if you use those two programs to correspond with the IT ServiceDesk system. If that option's not available, then using E-Mail is sufficient. Please keep in mind that if you submit a ticket to an IT service desk database that's not in your regular region, it might take up to two hours for the E-Mail message to the system for the same ticket to be recognized due to our replication schedule.")
Call RtItem.AddNewLine(2)
richstyle.Bold = True
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("It is for that reason that it's always preferable to correspond with the IT ServiceDesk system directly with your Notes Client or a Web Browser")
Call RtItem.AddNewLine(2)
richstyle.Bold = False
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("Another Hint: When you are inside the Indus Network, using the Notes client to access the ServiceDesk is best. When Outside of the Indus Network, a Web Browser is better")
Call RtItem.AddNewLine(2)
richstyle.Bold = True
Call rtitem.AppendStyle(richstyle)
richstyle.Fontsize = 12
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("Getting a list of your existing tickets:")
richstyle.Bold = False
Call rtitem.AppendStyle(richstyle)
richstyle.Fontsize = 10
Call rtitem.AppendStyle(richstyle)
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("Just send an empty mail message with the word; ")
richstyle.Bold = True
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("list")
richstyle.Bold = False
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText(" in the subject field. Case does not matter.")
Call RtItem.AddNewLine(2)
richstyle.Bold = True
Call rtitem.AppendStyle(richstyle)
richstyle.Fontsize = 12
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("Getting help on the IT Automated ServiceDesk system:")
richstyle.Bold = False
Call rtitem.AppendStyle(richstyle)
richstyle.Fontsize = 10
Call rtitem.AppendStyle(richstyle)
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("As with the list command, just send a message to your regional IT support desk address with the single command; ")
richstyle.Bold = True
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("help")
richstyle.Bold = False
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText(" in the subject field of your message. Again Case does not matter. You will also generate this message if you are sending from a non-Indus E-Mail account that doesn't have a Valid Indus E-Mail address in the Copy-To field")
Call RtItem.AddNewLine(2)
Call RTItem.AppendText("The following are the regional office E-Mail addresses and phone numbers")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("San Francisco - ITServiceDesk-SFO@Indus.com - (415) 904-5030, or (800) 664-6387 ext 5030")
Call RtItem.AddNewLine(1)
Call RtItem.AppendText("Atlanta, GA - ITServiceDesk-ATL@Indus.com - (770) 989-4357")
Call RtItem.AddNewLine(1)
Call RtItem.AppendText("Columbia, SC - ITServiceDesk-COL@Indus.com - (803) 935-8030 or (866) 467-4535")
Call RtItem.AddNewLine(1)
Call RtItem.AppendText("Pittsburgh, PA - ITServiceDesk-PIT@Indus.com - (412) 560-6130")
Call RtItem.AddNewLine(1)
Call RtItem.AppendText("Woking, UK - ITServiceDesk-LHR@Indus.com - +44 (0) 1483-794-196")
Call RtItem.AddNewLine(1)
Call RtItem.AppendText("Paris, FR - ITServiceDesk-CDG@Indus.com - +33 (0) 1-3930-1714")
Call RtItem.AddNewLine(1)
Call RtItem.AppendText("Although the address ITServiceDesk@Indus.com is a valid address, this will cause the ticket to be mailed to the San Francisco regional office. If your support is from a different office, it will take up to 2 hours for the ticket to appear there and be acted upon")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("Mailing to an IT Service desk database that's outside of your region (ie; if your support normally comes out of San Francisco, but you send a message to the Columbia region because you're on the East coast and need immediate support) will not guarrantee a quick turnaround as each office only monitors tickets for employees in their region. If you need immediate support that's outside of your normal region, please call the support line of a regional office closest to you instead. If you're in doubt as to what your normal region is, just look at the sender of this E-Mail. The address there should reflect the appropriate region for you.")
Call RtItem.AddNewLine(2)
Else

' Process "List" command

If Trim(Lcase(Subject)) = "list" Then
SomethingToMail = 1
Set TicketView = db.GetView("(TicketLookup)")
Set dc = TicketView.GetAllDocumentsByKey(IndusUser.Common)
Call RtItem.AppendText("Please remember that if you recently submitted a ticket via E-Mail to a Service Desk database that's outside of your region, that it takes up to 2 to 4 hours for it to show up on this server where the list is being taken.")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("Open tickets for " & IndusUser.Common)
Call RtItem.AddNewLine(2)
Set TicketDoc = dc.GetFirstDocument
If TicketDoc Is Nothing Then
Call RtItem.AppendText("***** You have no open IT ServiceDesk tickets ****")
Call RtItem.AddNewLine(2)
Else
Call RtItem.AppendText("Ticket # Description")
Call RtItem.AddNewLine(1)
While Not TicketDoc Is Nothing
Call RtItem.AppendText(TicketDoc.TicketNum(0) & " " & Trim(TicketDoc.BodyText(0)))
Call RtItem.AddNewLine(1)
Set TicketDoc = dc.GetNextDocument(TicketDoc)
Wend
End If
Else

' From this point on, we want to make Update and New ticket functions happen on the correct server.

If ITDBServer.Abbreviated = CurrentServer.Abbreviated Then

' See if this is a response to an existing ticket.
test = Trim(Strright(Ucase(Subject),"TICKET#"))
If test <> "" And Mid(test,5,1) = "-" Then
Set TicketView = db.GetView("(ByTicketNum)")
Set TicketDoc = TicketView.GetDocumentByKey(Test)

' Bogus Ticket number in the inquiry

If TicketDoc Is Nothing Then
SomethingToMail = 1
MailOutDoc.Subject = "[" & Db.Title & "] System - Error"
Call RtItem.AppendText("The ticket number; " & Test & " described in the subject line; " & Subject & " was not found")
Call RTItem.AddNewLine(2)
Call RtItem.AppendText("When adding to a new ticket, the subject line should read only;")
Call RTItem.AddNewLine(2)
Call RtItem.AppendText(" Re: Ticket# XXXX-XXXXX")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("Where XXXX-XXXXX is the ServiceDesk ticket number. For help, send a message to ITServiceDesk@Indus.com E-Mail address with only the word; ")
richstyle.Bold = True
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("help")
richstyle.Bold = False
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText(" appearing in the subject field of your message.")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("For a list of current tickets, send a message to your regional IT Service desk e-mail address (see help command) with only the command; ")
richstyle.Bold = True
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText("List")
richstyle.Bold = False
Call rtitem.AppendStyle(richstyle)
Call RtItem.AppendText(" appearing in the subject field of your mail message")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("Please keep in mind that if you recently submitted a ticket via E-Mail to a Service Desk database that's outside of your region, that it takes up to 2 to 4 hour for it to show up on this server where the list is being taken.")
Else

' Yes, update the ticket and send a confirming mail message back.
SomethingToMail = 1
MailOutDoc.Subject = "[" & Db.Title & "] Re: Ticket# " & TicketDoc.TicketNum(0)
Call RtItem.AppendText("This ticket has been updated")
Call RtItem.AddNewLine(2)
Call RtItem.AppendText("This ticket is currently " & TicketDoc.Status(0))
Call RTItem.AddNewLine(2)
Call RTItem.AppendText("The IT Service Desk ticket has been updated. Please save this message if you wish to correspond further with this ticket via E-Mail")
Call RTItem.AddNewLine(2)
Call AddHotspots(Db, PSPView, SPDoc,TicketDoc,RTItem, RichStyle)
Call RTitem.AddNewLine(2)
Desc = MailInRtItem.GetFormattedText (False,0)
If Desc <> "" Then
' Remove any of the forwarded stuff if they included history from the ticket system
If Instr(Desc,"Subject: Re: Ticket#") > 0 Then
Desc = Strleft(Desc,"Subject: Re: Ticket#")
For i = 1 To 9
Desc = Strleftback(Desc,Chr$(13))
Next
End If
TicketDoc.Resolution = Format(Now(),"mm/dd/yyyy hh:nn:ss AM/PM") & " by " & IndusUser.Common & ": " & desc & Chr(13) & Chr(10) & TicketDoc.Resolution(0)
EMailUpdate = TicketDoc.EMailUpdate(0)
If Isnumeric(EMailUpdate) Then EMailUpdate = EMailUpdate + 1 Else EMailUpdate = 1
TicketDoc.EMailUpdate = EMailUpdate
TicketDoc.LastUpdatedBy = "E-Mail"
End If
Call TicketDoc.Save(True, False, False)
End If
Else

' Create a new Ticket.

Set TicketDoc = New NotesDocument(db)
TicketDoc.Form = "Submission"
TicketDoc.TrName = IndusUser.Common
TicketDoc.Origin = "E-Mail"
Set TicketRtItem = New NotesRichTextItem(TicketDoc,"Body")
BodyString = MailInRtItem.GetFormattedText(False,0)
If Isempty(MailInRTItem.Embeddedobjects) And Not MailInDoc.HasItem("$Links") And MailInRTItem.Valuelength - Len(BodyString) < 1000 Then
TicketDoc.Body = MailInRtItem.GetFormattedText (False, 0)
Else
Call TicketRtItem.AppendRTItem(MailInRtItem)
End If
Set DateTime = New NotesDateTime( "" )
Call DateTime.SetNow
TicketDoc.Resolution = DateTime.LocalTime & " Ticket created via E-Mail " & Subject
TicketDoc.SCTAddressPhone = NABDoc.OfficePhoneNumber(0)
TicketDoc.PagerNumber = NABDoc.PhoneNumber_6(0)
TicketDoc.MobilePhone = NABDoc.CellPhoneNumber(0)
TicketDoc.NADept = NABDoc.Department(0)
TicketDoc.ShortName = NABDoc.ShortName(0)
TicketDoc.Division = NABDoc.Division(0)
TicketDoc.Location = NABDoc.Location(0)
TicketDoc.PreTrName = IndusUser.Common
TicketDoc.UserLocalMailServer = UserMailServer.Canonical
Set NABSView = NABDb.GetView("($Servers)")
Set NABSDoc = NABSView.GetDocumentByKey(ITDBServer.Canonical)
TicketDoc.ITServiceDeskHTTPName = NABSDoc.HTTP_ExternalURL(0)
Desc = MailInRtItem.GetFormattedText (False,0)
If Desc <> "" Then
TicketDoc.Resolution = Format(Now(),"mm/dd/yyyy hh:nn:ss AM/PM") & " by " & IndusUser.Common & ": " & desc & Chr(13) & Chr(10) & TicketDoc.Resolution(0)
End If
Success = TicketDoc.ComputeWithForm(False, False)
TicketDoc.DocURL = NABSDoc.HTTP_ExternalURL(0) & "/" & SPDoc.FilePath(0) & "/O/" & TIcketDoc.UniversalID
Call TicketDoc.Save(True, False, False)
SomethingToMail = 1
MailOutDoc.Subject = "[" & Db.Title & "] Re: Ticket# " & TicketDoc.TicketNum(0)
Call RtItem.AppendText("A New IT Service Desk ticket has been created for you")
Call RtItem.AddNewLine(2)
Call RTItem.AppendText("Please save this message if you wish to correspond further with this ticket via E-Mail or simply send a new message including the above Subject line to update this ticket via E-Mail. Please refrain from using 'Reply with history' as this usually just duplicates information already in the ticket. Also do not E-Mail attachments in any reply to this system as they will not be stored.")
Call RTItem.AddNewLine(2)
Call AddHotspots(Db, PSPView, SPDoc,TicketDoc,RTItem, RichStyle)
End If
End If
End If
End If

' If this doc passed the "Delivery Report Failure" test and we have something to mail, then mail it
' and remove the doc, otherwise, leave it here for the correct server to act on it.
If SomeThingToMail = 1 Then
Call MailOutDoc.Send(False)
Set TempDoc = MailInDoc
Set MailInDoc = MailInView.GetNextDocument(MailInDoc)
Call TempDoc.Remove(True)
Else
Set MailInDoc = MailInView.GetNextDocument(MailInDoc)
End If
Else
' We didn't pass the "Delivery Report Failure test. Just get rid of the doc.
Set TempDoc = MailInDoc
Set MailInDoc = MailInView.GetNextDocument(MailInDoc)
Call TempDoc.Remove(True)
End If
Wend
End Sub


Feedback response number WEBB9GWP49 created by ~Fritz Oprekonyettu on 03/05/2014

Can a notes application accept info... (~Yoshi Zenreber... 14.Feb.14)
. . Do you have to use mail? (~Martha Lopjipy... 20.Feb.14)
. . Group email (~Fred Umkivitch... 14.Feb.14)
. . . . Not sure that's it (~Yoshi Zenreber... 14.Feb.14)
. . . . . . Should work. (~Dan Kikiterobu... 15.Feb.14)
. . . . . . . . Can you do it after the fact? (~Yoshi Zenreber... 17.Feb.14)
. . . . . . . . . . Yes. (~Dan Kikiterobu... 17.Feb.14)
. . . . . . In case it's not clear... (~Ned Nimfanakon... 17.Feb.14)
. . . . . . . . Mailin Monitoring agent (~Fritz Oprekony... 5.Mar.14)




Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS