Outlook 2007 Copy Email Address in To Field

Status
Not open for further replies.

LMS

Senior Member
Outlook version
Email Account
Exchange Server
There is a story how I need to do this. If there is an email that has not been sent yet, but is open, do we have a macro that copies the email address in the To field, and closes the email not sending it? Here is the code I got before with copies from a field in a contact, but not from an email and its field that is open:

Public Sub CopyAddress()
Dim oContact As contactItem

Set oContact = ActiveExplorer().Selection.Item(1)
Set DataObj = New MSForms.DataObject
DataObj.SetText oContact.UserProperties("LinkedIn Webpage")
DataObj.PutInClipboard
End Sub
 
The To field is .To - it should work if you properly reference the mailitem instead of contactitem.

Do you need to copy to clipboard or just copy the field to use in another form?
 
Got it! Can please show me how to reference the mailitem. As I repeat, i don't have the understanding of these areas so if you can just give me the code to use that would be very helpful to me, which includes closing the email and not sending it.

As to the copy, that email address that is copied, I use the paste code you gave me which puts it in the Email1 field of a contact I select.
 
From another forum over time, I came with the following code that does it.
But here is next major problem, and if we can fix this right now, that would be wonderful!!
When I am on another webpage where I have people that I am connected with through that webpage, for example. LinkedIn, in the contact person area on the webpage there is an email address and when I click on it, it creates an email to that email address, and when I run the code, it closes it, but did not copy the email address in the To field.
What can we change so it copies from that email that is created when I click on an email address in the other webpage?

Public Sub CopyEmailAddress2()
Dim item
Dim inspector
Dim addresses
Dim Recip
Dim myinspector As outlook.inspector
Dim myItem As outlook.mailItem
Set inspector = Application.ActiveInspector
Set item = inspector.currentItem
addresses = ""
For Each Recip In item.Recipients
If Len(addresses) > 0 Then addresses = addresses & "; "
addresses = addresses & Recip.Address
Next
Set DataObj = New MSForms.DataObject
DataObj.SetText addresses
DataObj.PutInClipboard
Set myinspector = Application.ActiveInspector
Set myItem = myinspector.currentItem
myItem.Close olSave
End Sub
 
From another forum over time, I came with the following code that does it.
But here is next major problem, and if we can fix this right now, that would be wonderful!!
When I am on another webpage where I have people that I am connected with through that webpage, for example. LinkedIn, in the contact person area on the webpage there is an email address and when I click on it, it creates an email to that email address, and when I run the code, it closes it, but did not copy the email address in the To field.
What can we change so it copies from that email that is created when I click on an email address in the other webpage?

Public Sub CopyEmailAddress2()
Dim item
Dim inspector
Dim addresses
Dim Recip
Dim myinspector As outlook.inspector
Dim myItem As outlook.mailItem
Set inspector = Application.ActiveInspector
Set item = inspector.currentItem
addresses = ""
For Each Recip In item.Recipients
If Len(addresses) > 0 Then addresses = addresses & "; "
addresses = addresses & Recip.Address
Next
Set DataObj = New MSForms.DataObject
DataObj.SetText addresses
DataObj.PutInClipboard
Set myinspector = Application.ActiveInspector
Set myItem = myinspector.currentItem
myItem.Close olSave
End Sub


And I just changed Recip.Address to Recip.Name and it took care of it.
 
Yes.....unless you have other thoughts that are better.
 
That looks to be about the best way to do it. At least IMHO.
 
In My Humble Opinion
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Outlook 2007 Copy Text Field Using Outlook 8
Z Copy Outlook 2007 "AutoComplete Contacts” to Outlook 2010 Using Outlook 7
D Outlook 2007 Recovering E-Mails Using Outlook 0
W Transfer Outlook 2016 autocomplete file to Outlook 2007 Using Outlook 1
C Outlook 2007 Removing then adding account restores junk email processing Using Outlook 0
S Outlook 2007 crash linked to gdiplus.dll Using Outlook 0
S Outlook 2007 - Automatic purge fail Using Outlook 0
J outlook 2007 doesn't let me choose which .pst to search Using Outlook 2
D Outlook 2007 vs. Outlook 2010 -- ToDo Bar Using Outlook 0
D Outlook 2007 on 365 Using Outlook.com accounts in Outlook 2
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
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
Diane Poremsky Manually create a POP3 account in Outlook 2007 Using Outlook 0
J Can Click to Drag Custom Form Field But Cannot Drop When Designing in Outlook 2007 Outlook VBA and Custom Forms 2
L Outlook 2007 Font Using Outlook 3
J Outlook 2007 connector and Windows 10 Using Outlook 3
R Outlook 2007 - Shared Accounts and Resources without Exchange Server Using Outlook 0

Similar threads

Back
Top