Outlook 2007 Delete Email Addresses

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The following macro deletes the email address from the first email area. What can I change to delete from the email2 address, and also, the email3 address?

Sub DeleteEmail1()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder

Dim objItem As Object

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

On Error Resume Next

If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem

objItem.UserProperties("E-mail") = ""

objItem.Save
GoTo Leave
End If

Set objSelection = objApp.ActiveExplorer.Selection

For Each objItem In objSelection


objItem.UserProperties("E-mail") = ""



objItem.Save

Next
Leave:
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The macro is to change just to the second email field and then change just to the third email field. So what do I change each way please as I need to do it this morning! Thanks very much!
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The following macro deletes the email2 address but I only shows up as deleted if I save and close the contact and open up the contact....so is there a way that is saves the contact without having to save and close and open it?

Public Sub DeleteEmail2()
Dim currentExplorer As Explorer
Dim Selection As Selection
Dim obj As Object

Set currentExplorer = Application.ActiveExplorer
Set Selection = currentExplorer.Selection

On Error Resume Next

For Each obj In Selection

Set objContact = obj

With objContact
If .Email2Address <> "" Then
.Email2Address = ""
.Save
End If
End With


Err.Clear
Next


Set obj = Nothing
Set objContact = Nothing

End Sub
 
Last edited:

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Well, this: .Save should save it - but it sounds like it's not getting refreshed. if you didn't customize the fields so they are each visible on screen, try selecting a different email address field in the email dropdown.

Are you using it on one contact or a selection of several contacts?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This works only on the currently open contact- and the address is removed, even if i don't switch address fields to refresh it. I noticed the display name field wasn't cleared and added that to it.

Code:
Public Sub DeleteEmail2()

Dim objcontact As ContactItem
On Error Resume Next


Set objcontact = Application.ActiveInspector.CurrentItem

With objcontact
If .Email2Address <> "" Then
.Email2Address = ""
.Email2DisplayName = ""
.Save
End If
End With


Err.Clear
Set objcontact = Nothing

End Sub
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I will try what you showed me above and let you know right away. And also, what can we add if I select a list of contacts from a folder....as before you showed me how to change the fields of a list of contacts that I select.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Here is what I learned, and to tell you! As to the email2 on the dropdown field of the email addresses, it deletes and I don't have to save and close and open the contact. But I added another field and the display is _RecipientControl6 and the field that you put in it is E-mail 2, and when I add to that field and save, close and open, it shows up on the dropdown field, and as to that additional field, it does not delete it until I save, close and open the contact.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Here is what I learned, and to tell you! As to the email2 on the dropdown field of the email addresses, it deletes and I don't have to save and close and open the contact. But I added another field and the display is _RecipientControl6 and the field that you put in it is E-mail 2, and when I add to that field and save, close and open, it shows up on the dropdown field, and as to that additional field, it does not delete it until I save, close and open the contact.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Here is the code that based on what you showed me before in other areas to delete, the following code deletes the email 2 address when I select the list of contacts, but again, if I run this when I open one contact, it does not delete it until I save, close and open the contact again....also, it does it on the dropdown field of email addresses without saving, closing and opening the contact.

Sub Delete_DeleteEmail2test2()
Dim objApp As Application
Dim objNS As NameSpace
Dim objFolder As MAPIFolder

Dim objItem As Object

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")

On Error Resume Next

If TypeName(objApp.ActiveWindow) = "Inspector" Then
Set objItem = objApp.ActiveInspector.currentItem

objItem.UserProperties("E-mail 2") = ""


objItem.Save
GoTo Leave
End If


Set objSelection = objApp.ActiveExplorer.Selection

For Each objItem In objSelection

objItem.UserProperties("E-mail 2") = ""


objItem.Save

Next

Leave:
Set objItem = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
so it behaves differently on custom fields? Where does the custom field get it's data from? If it reads a default field, the custom field it's set to update on some action, probably open by the sounds of it. So you need to clear the default field then save and do the action for the custom field to update.

I thought 'automatically' updated on change.

properties.png
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
The place a created, I choosed the field you show above, and that works when I select a list of contacts, but not when I just open one contact.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
That's because the selected contacts are not all open - the single contacts needs to be closed and reopened. Is the field set to calculate automatically?
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I don't understand what you said....I just open the contact, run the code, and when I save and close the contact, it deleted the email2 address.....I just want it to delete it without having to save and close and open again. Is there a way to do that?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
The email2 address is in a custom field : objItem.UserProperties("E-mail 2") - where is it getting the data for that field? Are you entering it directly in the Email 2 custom field or is it reading Outlook's default Email2Address field?
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I just have the field from Outlook that is E-mail 2 which is the value of the area I created.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
The problem is that the custom field is reading the default field and it definitely won't update until the form is saved - it should update if you switch tabs (multiple pages) and might update if you move to another field. I don't know of a way to force an update.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
I appreciate your help as usual!!

Also, is there a code that saves the contact but does not close it? As I have a code that saves and closes the contact.
 

LMS

Senior Member
Outlook version
Outlook 2007
Email Account
Exchange Server
And here is my code that saves and closes the contract, so what can we change so it just saves the contract without closing it:

Public Sub SaveCloseContact()

Dim myinspector As outlook.inspector

Dim myItem As outlook.contactItem


Set myinspector = Application.ActiveInspector

Set myItem = myinspector.currentItem

myItem.Close olSave


End Sub
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
This:
myItem.Close olSave

changed to
myItem.save

will save without closing.
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
L Outlook 2007 Delete and Paste Between Fields Using Outlook 25
S can't delete duplicate account under Outlook 2007 (Win 7) Using Outlook 16
K Can't Delete Mail from Deleted Mail Folder, Outlook 2007, Windows XP Using Outlook 3
V Incoming message too large to receive in Outlook 2007 - how to delete it so both send/receive again Using Outlook 2
L How can I delete stationery from Actions, New Mail Message Using in outlook 2007? Using Outlook 6
M Cannot delete an e-mail with a large attachment from the OUTLOOK 2007 outbox. Using Outlook 1
T 'Reviewer' access to my task list in Outlook 2007 is allowing the delegate to delete individual tasks Using Outlook 1
C Outlook 2007 locks up every time I delete calendar reminder Using Outlook 1
S Cannot Delete Folders in Outlook 2007 Using Outlook 4
B Re: Outlook 2007 delete rules will not work Using Outlook 2
D I have Outlook 2007 and want to delete messages from the Yahoo server after downloading them. The instructions were not in your data base. How do I Using Outlook 1
M Can't delete an email that won't clear from the outbox. Outlook 2007 Using Outlook 2
A Delete Messages in Outlook 2007 Using Outlook 1
G How do I delete outlook 2010 trial so my outlook 2007 works without errors Using Outlook 2
S Looking for client-side method (Outlook 2007/Exchange 2007) for users to delete Outlook VBA and Custom Forms 2
B Outlook 2007- Doesn't complete send/receive unless close Outllok, delete the background task and the Using Outlook 3
S Verwendung von Outlook 2007 Using Outlook 0
A Arthur needs help with 2007 Outlook e-mail Using Outlook.com accounts in Outlook 3
M PST import from Outlook 2007 to 2010 - Address Book contacts all in 1 group Using Outlook 4
S outlook 2007 calendar search Using Outlook 6
B Migrate Outlook 2007 to Office 365 Using Outlook 3
X I have met my waterloo trying to resolve embedded graphics problem with outlook 2007 and now 2016 Using Outlook 1
R Outlook 2007 only loads some appointments Using Outlook 0
C Move Outlook 2007 to new PC with Outlook 365 Using Outlook 3
J Outlook 2007 Hide Messages Option not Available Using Outlook 2
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 4
S Outlook 2007 Calendar instant search problem. Windows 7 Using Outlook 0
B Server errors Outlook 2007 Using Outlook 1
S Reboot of frozen windows7 results in changed outlook 2007 settings Using Outlook 1
S Outlook 2007 printing wrong email address at top of page Using Outlook 8
M Configure outlook 2007 to accept digital signatures Using Outlook 2
D Outlook 2007 crashes when opening an email Using Outlook 2
R New chap saying hello and needing advice on Outlook 2007 thumbnails Using Outlook 3
icacream From Outlook 2007 to 2016 ! Using Outlook 9
vodkasoda Object could not be found Error in Outlook 2007 Outlook VBA and Custom Forms 5
S Outlook 2007: Address Cards allow entering text! Why? Using Outlook 3
S View Appointment in Text Wrap in Outlook 2007 Month Calendar View Using Outlook 0
L Outlook 2007 Separate the Send/Receive functions Using Outlook 2
M Outlook 2007 Contacts Glitch: Creating a new email Using Outlook 1
C Move from Outlook 2007 Enterprise (MOE) to Outlook Pro plus 2007 Using Outlook 1
J reinstalling Outlook 2007 asking for user name & password Using Outlook 14
P outlook addin unloaded in office 2007 Using Outlook 0
B Fonts in Outlook 2007 Using Outlook 4
R Add Exchange Account to existing POP3 Outlook 2007 Profile Using Outlook 0
C out of space in file group Outlook 2007 Using Outlook 2
A Moving archived contents in Outlook 2007 back into working folders Using Outlook 0
P Outlook 2007 Email Categorization using VBA Outlook VBA and Custom Forms 1
M Unable to Configure Gmail Account in Outlook 2007 Using Outlook 1
R Outlook 2007 or 2010 - Lock Down Functionality Outlook VBA and Custom Forms 3
S Outlook 2007, windows 10 Font size Using Outlook 1
Similar threads


















































Top