Reply all by attachment name

Status
Not open for further replies.

Vijay

Member
Outlook version
Outlook 2010 64 bit
Email Account
Hi All,

my first post here,

i have this below code working great as it is searching email with subject line and replying to it.

the same task can i search by "Attachment name" and make reply ?

here is the code

Try
Dim olApp As Outlook.Application
Dim olNs As Outlook.NameSpace

Dim olMail As Outlook.MailItem




olApp = New Outlook.Application
olNs = olApp.GetNamespace("MAPI")
Dim Fldr As MAPIFolder


Fldr = olNs.GetDefaultFolder(OlDefaultFolders.olFolderInbox)


For Each olMail In Fldr.Items


If InStr(olMail.Submitted, TextBox1.Text) <> 0 Then
olMail.Display()



End If
Next olMail

Catch ex As System.Exception

MsgBox(Err.Description)


End Try

End Sub
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
The same solution: Within the loop through the emails, use another loop through olMail.Attachments, and search for the DisplayName of the attachment.
 

Vijay

Member
Outlook version
Outlook 2010 64 bit
Email Account
Hi Michael,
thanks for the reply, am not finding the display name for the same.. could you give me some example
 

Vijay

Member
Outlook version
Outlook 2010 64 bit
Email Account
my code is pasted in the starting of this thread.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Pleas show your changes subject to the attachments, so we can see what's going on.
 

Vijay

Member
Outlook version
Outlook 2010 64 bit
Email Account
Try
Dim olApp As Outlook.Application
Dim olNs As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim oObject As Object
Dim i As Integer




olApp = New Outlook.Application
olNs = olApp.GetNamespace("MAPI")

Dim Fldr As MAPIFolder
Fldr = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
i = 1

For Each oObject In Fldr.Items

If TypeOf oObject Is Outlook.MailItem Then
olMail = CType(oObject, Outlook.MailItem)



If InStr(olMail.attachments.displayname, TextBox1.Text) <> 0 Then
olMail.Display()
i = i + 1
End If
End If


Next oObject


Catch ex As System.Exception
MsgBox(Err.Description)
End Try

End Sub


whats wrong here. ?
 

Vijay

Member
Outlook version
Outlook 2010 64 bit
Email Account
Well however i am succesfully able to display the mailitem by searching through attachment name however new issue is ...

mails getting displayed but not reply all happening.


Try
Dim olApp As Outlook.Application
Dim olNs As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim oObject As Object
Dim i As Integer
Dim objAtt As Outlook.Attachment


olApp = New Outlook.Application
olNs = olApp.GetNamespace("MAPI")

Dim Fldr As MAPIFolder
Fldr = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
i = 1


For Each oObject In Fldr.Items



If TypeOf oObject Is Outlook.MailItem Then
olMail = CType(oObject, Outlook.MailItem)

For Each objAtt In olMail.Attachments
If InStr(objAtt.DisplayName, TextBox1.Text) <> 0 Then
olMail.Display()
olMail.ReplyAll()

i = i + 1

End If

Next objAtt

End If

Next oObject




Catch ex As System.Exception
MsgBox(Err.Description)
End Try

End Sub
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
The ReplyAll function returns a new MailItem object. If you want to send it, call that new item`s Send procedure.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A Edit attachment Save and Reply Outlook VBA and Custom Forms 0
C Outlook Attachment List in Reply Header Using Outlook 3
C Reply to all or reply to the To: Field with attachment Using Outlook 1
J Reply All and No attachment Reminder Using Outlook 14
D Outlook 2010 Client crashes on new message, reply, forward, send as attachment Using Outlook 3
D Outlook 2010 crashes when I select new message, reply, forward or send as attachment Using Outlook 3
G Custom Forms: Attachment to be included in Reply Outlook VBA and Custom Forms 1
W Reply to email Using Outlook 0
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
B Adding signature to bottom of VBA reply email Outlook VBA and Custom Forms 1
C UDFs Reply vs Forward Outlook VBA and Custom Forms 2
ThinkToday Calculate reply time of outlook mail Using Outlook 1
W Replyin to the reply-to email address Outlook VBA and Custom Forms 0
D Reply with a template loose the sender's embedded image Outlook VBA and Custom Forms 0
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
J Outlook Reply > From > Other Email Address... > Address Not Showing in Sent Items... From Email Outlook VBA and Custom Forms 0
M Delete headers in Inline reply Outlook VBA and Custom Forms 5
E reply Using Outlook 0
Healy Consultants Macro to remove inside organization distribution list email address when reply to all recepients Outlook VBA and Custom Forms 0
B resend if no reply and send an automatic reminder Outlook VBA and Custom Forms 0
evdbogaard Reply with only last message cited Using Outlook 1
B Reply and replyall macro is not working Outlook VBA and Custom Forms 1
mctabish Setting "Reply To" based on inbox Outlook VBA and Custom Forms 2
Rupert Dragwater Deleted email address keeps showing up in reply Using Outlook 12
B When working on emails in a certain folder, when I hit reply or reply all, I would like it re always reply all and add an email address to send to Outlook VBA and Custom Forms 3
R How Do I insert images in and Auto Reply Using Outlook 3
D Disable or hide "reply" and "reply to all" and "forward" in email from access vba Outlook VBA and Custom Forms 1
M Reply Inline With a Outlook Template Outlook VBA and Custom Forms 6
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
O On click,I want to change subject line of selected mail and then reply to particular email and move Using Outlook 3
J VBA Run When Reply Outlook VBA and Custom Forms 4
D Font in Reply is much larger than normal, how to reset ...? Using Outlook 4
K add pdf to every reply or forward Outlook VBA and Custom Forms 1
A VB to "reply all" email items stored in a folder of outlook with adding a new message Outlook VBA and Custom Forms 0
K Extract email address from body and auto-reply outlook Using Outlook 1
T In-line reply style in Outlook Outlook VBA and Custom Forms 20
N Lookup Value From Excel and Reply With Matching Value Using Outlook 0
G Outlook 2016: reply icon not showing when replied from mobile Using Outlook 3
J Remove extra line above signature in reply Outlook VBA and Custom Forms 5
ashcosta2 Auto Reply rule based on speficied time Outlook VBA and Custom Forms 0
D Reply Problem with Outlook.com account Using Outlook.com accounts in Outlook 0
H send reminder if no reply received on first or original email using macro Using Outlook 2
Diane Poremsky Reply to All Includes My Address New Slipstick.com Articles 0
F Room Mailbox Reply Exchange Server Administration 0
N How to add Dear & mail receipts name while reply to that mail in outlook2007 Outlook VBA and Custom Forms 1
J Force account selection for sending reply emails Using Outlook 1
J Adding Reply & Delete to main toolbar? Using Outlook 0
Diane Poremsky Outlook Crashes When You Reply or Create a New Message New Slipstick.com Articles 0

Similar threads

Top