Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   delete email once it has been replyed to in outlook, through VBA code (http://www.outlookbanter.com/outlook-vba/86546-delete-email-once-has-been.html)

jinjay February 18th 09 09:57 AM

delete email once it has been replyed to in outlook, through VBA code
 
Hey Guys,

I'm new to this forum so if i miss anything, apologizes.

I am working in outlook 2003, my goal is to write a code to be able to delete a message once it has been replied to. I have archived this with the following code:-
but now i need to edit this so it only works with a certain subject heading and not every email. Please help

can the code be change so it deletes on predefined subject heading upon hitting reply. at the moment it is deleting any message that is replied to.

Option Explicit
Private WithEvents ReplyButton As Office.CommandBarButton
Private WithEvents m_Inspectors As Outlook.Inspectors
Private m_Mail As Outlook.MailItem

Private Sub Application_Startup()
Set ReplyButton = Application.ActiveExplorer.CommandBars.FindControl (, 354)
Set m_Inspectors = Application.Inspectors
End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
On Error Resume Next
If Not m_Mail Is Nothing Then
m_Mail.Delete
Set m_Mail = Nothing
End If
End Sub

Private Sub ReplyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean _
)
On Error Resume Next

If TypeOf Application.ActiveWindow Is Outlook.Explorer Then
Set m_Mail = Application.ActiveExplorer.Selection(1)
Else
Set m_Mail = Application.ActiveInspector.CurrentItem
End If
End Sub




I am trying to change the following code so it only deleted

Ken Slovak - [MVP - Outlook] February 18th 09 02:42 PM

delete email once it has been replyed to in outlook, through VBA code
 
If I understand what you are asking then just test the m_Mail.Subject
property against your string.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"jinjay" wrote in message
...

Hey Guys,

I'm new to this forum so if i miss anything, apologizes.

I am working in outlook 2003, my goal is to write a code to be able to
delete a message once it has been replied to. I have archived this with
the following code:-
but now i need to edit this so it only works with a certain subject
heading and not every email. Please help

can the code be change so it deletes on predefined subject heading upon
hitting reply. at the moment it is deleting any message that is replied
to.

Option Explicit
Private WithEvents ReplyButton As Office.CommandBarButton
Private WithEvents m_Inspectors As Outlook.Inspectors
Private m_Mail As Outlook.MailItem

Private Sub Application_Startup()
Set ReplyButton =
Application.ActiveExplorer.CommandBars.FindControl (, 354)
Set m_Inspectors = Application.Inspectors
End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
On Error Resume Next
If Not m_Mail Is Nothing Then
m_Mail.Delete
Set m_Mail = Nothing
End If
End Sub

Private Sub ReplyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean _
)
On Error Resume Next

If TypeOf Application.ActiveWindow Is Outlook.Explorer Then
Set m_Mail = Application.ActiveExplorer.Selection(1)
Else
Set m_Mail = Application.ActiveInspector.CurrentItem
End If
End Sub




I am trying to change the following code so it only deleted




--
jinjay



Michael Bauer [MVP - Outlook] February 18th 09 04:45 PM

delete email once it has been replyed to in outlook, through VBA code
 

It's always funny, how some people can "write" such a complicated code but
aren't able to do the smallest changes on their own...

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en



Am Wed, 18 Feb 2009 09:57:58 +0000 schrieb jinjay:

Hey Guys,

I'm new to this forum so if i miss anything, apologizes.

I am working in outlook 2003, my goal is to write a code to be able to
delete a message once it has been replied to. I have archived this with
the following code:-
but now i need to edit this so it only works with a certain subject
heading and not every email. Please help

can the code be change so it deletes on predefined subject heading upon
hitting reply. at the moment it is deleting any message that is replied
to.

Option Explicit
Private WithEvents ReplyButton As Office.CommandBarButton
Private WithEvents m_Inspectors As Outlook.Inspectors
Private m_Mail As Outlook.MailItem

Private Sub Application_Startup()
Set ReplyButton =
Application.ActiveExplorer.CommandBars.FindControl (, 354)
Set m_Inspectors = Application.Inspectors
End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
On Error Resume Next
If Not m_Mail Is Nothing Then
m_Mail.Delete
Set m_Mail = Nothing
End If
End Sub

Private Sub ReplyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean _
)
On Error Resume Next

If TypeOf Application.ActiveWindow Is Outlook.Explorer Then
Set m_Mail = Application.ActiveExplorer.Selection(1)
Else
Set m_Mail = Application.ActiveInspector.CurrentItem
End If
End Sub




I am trying to change the following code so it only deleted


jinjay February 19th 09 10:33 AM

Quote:

Originally Posted by Michael Bauer [MVP - Outlook] (Post 292889)
It's always funny, how some people can "write" such a complicated code but
aren't able to do the smallest changes on their own...

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en



Am Wed, 18 Feb 2009 09:57:58 +0000 schrieb jinjay:

Hey Guys,

I'm new to this forum so if i miss anything, apologizes.

I am working in outlook 2003, my goal is to write a code to be able to
delete a message once it has been replied to. I have archived this with
the following code:-
but now i need to edit this so it only works with a certain subject
heading and not every email. Please help

can the code be change so it deletes on predefined subject heading upon
hitting reply. at the moment it is deleting any message that is replied
to.

Option Explicit
Private WithEvents ReplyButton As Office.CommandBarButton
Private WithEvents m_Inspectors As Outlook.Inspectors
Private m_Mail As Outlook.MailItem

Private Sub Application_Startup()
Set ReplyButton =
Application.ActiveExplorer.CommandBars.FindControl (, 354)
Set m_Inspectors = Application.Inspectors
End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
On Error Resume Next
If Not m_Mail Is Nothing Then
m_Mail.Delete
Set m_Mail = Nothing
End If
End Sub

Private Sub ReplyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean _
)
On Error Resume Next

If TypeOf Application.ActiveWindow Is Outlook.Explorer Then
Set m_Mail = Application.ActiveExplorer.Selection(1)
Else
Set m_Mail = Application.ActiveInspector.CurrentItem
End If
End Sub




I am trying to change the following code so it only deleted

Thanks for all the responses,
i did not write the code but it was available from another site. I am not sure have to go about making this change as i have not programmed in VBA before, your help will be really appreciated

Michael Bauer [MVP - Outlook] February 21st 09 10:29 AM

delete email once it has been replyed to in outlook, through VBA code
 



i did not write the code but it was available from another site.


That's obvious. If you copy and re-publish code from others, it would be
nice to tell where you got the code from.

In ReplyButton_Click you can check the Subject property after setting the
m_Mail variable. If it's not what you're lookign for, set m_Mail=Nothing.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Thu, 19 Feb 2009 10:33:25 +0000 schrieb jinjay:

'Michael Bauer [MVP - Outlook Wrote:
;292889']It's always funny, how some people can "write" such a
complicated code but
aren't able to do the smallest changes on their own...

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en



Am Wed, 18 Feb 2009 09:57:58 +0000 schrieb jinjay:
-
Hey Guys,

I'm new to this forum so if i miss anything, apologizes.

I am working in outlook 2003, my goal is to write a code to be able to
delete a message once it has been replied to. I have archived this
with
the following code:-
but now i need to edit this so it only works with a certain subject
heading and not every email. Please help

can the code be change so it deletes on predefined subject heading
upon
hitting reply. at the moment it is deleting any message that is
replied
to.

Option Explicit
Private WithEvents ReplyButton As Office.CommandBarButton
Private WithEvents m_Inspectors As Outlook.Inspectors
Private m_Mail As Outlook.MailItem

Private Sub Application_Startup()
Set ReplyButton =
Application.ActiveExplorer.CommandBars.FindControl (, 354)
Set m_Inspectors = Application.Inspectors
End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
On Error Resume Next
If Not m_Mail Is Nothing Then
m_Mail.Delete
Set m_Mail = Nothing
End If
End Sub

Private Sub ReplyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean _
)
On Error Resume Next

If TypeOf Application.ActiveWindow Is Outlook.Explorer Then
Set m_Mail = Application.ActiveExplorer.Selection(1)
Else
Set m_Mail = Application.ActiveInspector.CurrentItem
End If
End Sub




I am trying to change the following code so it only deleted-


Thanks for all the responses,
i did not write the code but it was available from another site. I am
not sure have to go about making this change as i have not programmed
in VBA before, your help will be really appreciated


jinjay February 23rd 09 05:20 PM

Quote:

Originally Posted by Michael Bauer [MVP - Outlook] (Post 293369)

i did not write the code but it was available from another site.


That's obvious. If you copy and re-publish code from others, it would be
nice to tell where you got the code from.

In ReplyButton_Click you can check the Subject property after setting the
m_Mail variable. If it's not what you're lookign for, set m_Mail=Nothing.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


Am Thu, 19 Feb 2009 10:33:25 +0000 schrieb jinjay:

'Michael Bauer [MVP - Outlook Wrote:
;292889']It's always funny, how some people can "write" such a
complicated code but
aren't able to do the smallest changes on their own...

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en



Am Wed, 18 Feb 2009 09:57:58 +0000 schrieb jinjay:
-
Hey Guys,

I'm new to this forum so if i miss anything, apologizes.

I am working in outlook 2003, my goal is to write a code to be able to
delete a message once it has been replied to. I have archived this
with
the following code:-
but now i need to edit this so it only works with a certain subject
heading and not every email. Please help

can the code be change so it deletes on predefined subject heading
upon
hitting reply. at the moment it is deleting any message that is
replied
to.

Option Explicit
Private WithEvents ReplyButton As Office.CommandBarButton
Private WithEvents m_Inspectors As Outlook.Inspectors
Private m_Mail As Outlook.MailItem

Private Sub Application_Startup()
Set ReplyButton =
Application.ActiveExplorer.CommandBars.FindControl (, 354)
Set m_Inspectors = Application.Inspectors
End Sub

Private Sub m_Inspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
On Error Resume Next
If Not m_Mail Is Nothing Then
m_Mail.Delete
Set m_Mail = Nothing
End If
End Sub

Private Sub ReplyButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean _
)
On Error Resume Next

If TypeOf Application.ActiveWindow Is Outlook.Explorer Then
Set m_Mail = Application.ActiveExplorer.Selection(1)
Else
Set m_Mail = Application.ActiveInspector.CurrentItem
End If
End Sub




I am trying to change the following code so it only deleted-


Thanks for all the responses,
i did not write the code but it was available from another site. I am
not sure have to go about making this change as i have not programmed
in VBA before, your help will be really appreciated


thanks for your help i managed to figure it out


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com