Vba Platform doesn't recognize as macro code

Hommer

New Member
Joined
Sep 10, 2014
Messages
5
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 ?

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]


 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Nobody has an answer to what?

I explained to the OP over there that the code is for an Outlook event.

It doesn't belong in Excel and it's not a macro.
 
Upvote 0
Nobody has an answer to what?

I explained to the OP over there that the code is for an Outlook event.

It doesn't belong in Excel and it's not a macro.

How I can run this code in outlook? I tried but I didn't receive any result.
Is there any option to combine the code built in excel with this code in outlook?
Since I am a beginner in this field do you have any suggestion for what I am thinking to do( the form that I explained in the first post)?

Thank you man for your time.
 
Upvote 0

Forum statistics

Threads
1,196,042
Messages
6,013,052
Members
441,746
Latest member
ArtemisAlex

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top