User Profile
Amisha35
Copper Contributor
Joined 3 years ago
User Widgets
Recent Discussions
Replay from excel - Any one ??
I just need my own code to search in shared mails also. I have this VBA code that look up from excel to outlook based on cell value it should find the thread and replay to latest mail. but the issue is that this code look only at my default inbox. What i need is that excel should look into all the folders and shared folders to find the mail and replay. Sub ReplyAllLastEmailFromInboxAndSent() Dim olApp As Outlook.Application Dim SubFolder As Folder Dim olNs As Namespace Dim Fldr As MAPIFolder Dim objMail As Object Dim objReplyToThisMail As MailItem Dim lngCount As Long Dim objConversation As Conversation Dim objTable As Table Dim objVar As Variant Dim strBody As String Dim searchFolderName As String Set olApp = Session.Application Set olNs = olApp.GetNamespace("MAPI") Set Fldr = olNs.GetDefaultFolder(olFolderSentMail) searchFolderName = "'" & Outlook.Session.GetDefaultFolder(olFolderInbox).FolderPath & "','" & Outlook.Session.GetDefaultFolder(olFolderSentMail).FolderPath & "'" lngCount = 1 For Each objMail In Fldr.Items If TypeName(objMail) = "MailItem" Then If InStr(objMail.Subject, ActiveCell.Value) <> 0 Then Set objConversation = objMail.GetConversation Set objTable = objConversation.GetTable objVar = objTable.GetArray(objTable.GetRowCount) Set objReplyToThisMail = olApp.Session.GetItemFromID(objVar(UBound(objVar), 0)) With objReplyToThisMail.ReplyAll strBody = "Dear " & "<br>" & _ "<p>" & _ "<p>Thank you," & vbCrLf .HTMLBody = strBody & .HTMLBody .Display End With Exit For End If End If Next objMail Set olApp = Nothing Set SubFolder = Nothing Set olNs = Nothing Set Fldr = Nothing Set objMail = Nothing Set objReplyToThisMail = Nothing lngCount = Empty Set objConversation = Nothing Set objTable = Nothing If IsArray(objVar) Then Erase objVar End Sub1.3KViews0likes5Comments
Recent Blog Articles
No content to show