HI everybody.
I found this code on the internet. The idea is to reply to the e-mail based on subject.
No clue why vba platform doesn’t’ recognize that as a macro code. When I click run, vba platform doesn’t list this code as normal.
I also tried this in vba for outlook, but neither there I can't see any result.
I am trying to build a form.
Basically what I do is, receive an e-mail describing the task. go online, finalize the task and send back an e-mail.
I builded a macro for doing all the online process. So now i need to respond back, saying for example: I finalized the task, thank you.
Usually the e-mails have CC contact.
I never used vba for outlook before. Today was the first time.
Since I don't have to much knowledge on this field i would really appreciate if you give me an orientation and also tell me which vba is better to accomplish my task ?
I found this code on the internet. The idea is to reply to the e-mail based on subject.
No clue why vba platform doesn’t’ recognize that as a macro code. When I click run, vba platform doesn’t list this code as normal.
I also tried this in vba for outlook, but neither there I can't see any result.
I am trying to build a form.
Basically what I do is, receive an e-mail describing the task. go online, finalize the task and send back an e-mail.
I builded a macro for doing all the online process. So now i need to respond back, saying for example: I finalized the task, thank you.
Usually the e-mails have CC contact.
I never used vba for outlook before. Today was the first time.
Since I don't have to much knowledge on this field i would really appreciate if you give me an orientation and also tell me which vba is better to accomplish my task ?
Code:
[COLOR=#333333][FONT=Segoe UI]Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim mai As Object
Dim newMail As MailItem
Dim intInitial As Integer
Dim intFinal As Integer
Dim strEntryId As String
Dim intLength As Integer
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
Dim myDestFolder2 As Outlook.MAPIFolder
Dim strSubject, strTemp As String[/FONT][/COLOR]
[COLOR=#333333][FONT=Segoe UI]Set myNameSpace = Application.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(6)
Set myDestFolder = myInbox.Folders("Personal")
Set myDestFolder2 = myInbox.Folders("U18")[/FONT][/COLOR]
[COLOR=#333333][FONT=Segoe UI] intInitial = 1
intLength = Len(EntryIDCollection)
intFinal = InStr(intInitial, EntryIDCollection, ",")
Do While intFinal <> 0
strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intFinal - intInitial))
Set mai = Application.Session.GetItemFromID(strEntryId)
If mai.Subject = "Hello" Then
Set newMail = Application.CreateItem(olMailItem)
newMail.Body = "Hi"
newMail.To = mai.SenderEmailAddress
newMail.Display
End If
intInitial = intFinal + 1
intFinal = InStr(intInitial, EntryIDCollection, ",")
Loop
strEntryId = Strings.Mid(EntryIDCollection, intInitial, (intLength - intInitial) + 1)
Set mai = Application.Session.GetItemFromID(strEntryId)
If mai.Subject = "Hello" Then
Set newMail = Application.CreateItem(olMailItem)
newMail.Body = "Hi"
newMail.To = mai.SenderEmailAddress
newMail.Display
End If
End Sub[/FONT][/COLOR]