I have a script that creates tasks from emails in Outlook - currently it just takes the email subject and makes it the task title, which is fine except I want to get rid of the first portion of the subject line up to a certain point.
The email subjects always start the same (although the ticket number is different), an example subject would be:
New Ticket: 3416 - School: School1 - Room: 158 - Desc: Broken PC
The ticket number changes - but I would like to remove everything up to and including "School:"
So we would be left with something like this:
School1 - Room: 158 - Desc: Broken PC
The script I am currently using is this:
Sub MakeTaskFromMail2(MyMail As Outlook.MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim objTask As Outlook.TaskItem
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
Set objTask = Application.CreateItem(olTaskItem)
With objTask
.subject = olMail.subject
.DueDate = olMail.SentOn
.Body = olMail.Body
End With
Call CopyAttachments(olMail, objTask)
objTask.Save
Set objTask = Nothing
Set olMail = Nothing
Set olNS = Nothing
End Sub
Sub CopyAttachments(objSourceItem, objTargetItem)
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
strPath = fldTemp.Path & "\"
For Each objAtt In objSourceItem.Attachments
strFile = strPath & objAtt.FileName
objAtt.SaveAsFile strFile
objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
fso.DeleteFile strFile
Next
Set fldTemp = Nothing
Set fso = Nothing
End Sub
Any help on how to separate this out and remove the first portion would be very helpful.
I don't believe it will be too hard to do - but my knowledge of VB is pretty limited.
*Edit - removed vb.net as it is not appropriate here.