Outlook 2007 Code for Note Fields of Appointment

Status
Not open for further replies.
Putting the if line aside, is there a macro that when I select or open a contact, it copies the email address of the contact, as I found another way to paste it in the calendar body but need a macro to copy the email address first?
 
Yes, that is easily done. The code sample at http://www.slipstick.com/developer/create-deferred-birthday-message-contact/ shows how to do it (and more) - basically, you need to identify the selected item and get the email1address field. if you want to copy the address to the clipboard, see http://www.slipstick.com/developer/code-samples/paste-clipboard-contents-vba/ - but you should use the field name if possible.

This quickie example creates an email message - you can create any outlook item. To use with open or selected item, use the getcurrentitem function, not ActiveExplorer.

Public Sub GetContact()

If TypeName(ActiveExplorer.Selection.Item(1)) = "ContactItem" Then
Set oContact = ActiveExplorer.Selection.Item(1)

Dim objMsg As MailItem

Set objMsg = Application.CreateItem(olMailItem)
objMsg.body = oContact.Email1Address
'displays the message form so you can enter more text
objMsg.Display

Set objMsg = Nothing

End Sub
 
Thanks very much but I don't understand.....I just need the simple code that copies the email address and does not paste it or do anything else with it as another part of what I have, will do the pasting....Can you just post the simple code please? Thanks so much!!
 
This is what reads the address - oContact.Email1Address - if your other code pastes from the clipboard, this won't work. It doesn't copy it, it only reads it. If you are going to paste it, you need code like this:

Sub CapturetoClipbaord()

Dim oContact As ContactItem

DataObj As MSForms.DataObject
Set oContact= ActiveExplorer().Selection.Item(1)
Set DataObj = New MSForms.DataObject
DataObj.SetText oContact.Email1Address
DataObj.PutInClipboard

End Sub

- - - Updated - - -

This is what reads the address - oContact.Email1Address - if your other code pastes from the clipboard, this won't work. It doesn't copy it, it only reads it. If you are going to paste it, you need code like this:




Sub CapturetoClipbaord()


Dim oContact As ContactItem


DataObj As MSForms.DataObject

Set oContact= ActiveExplorer().Selection.Item(1)
Set DataObj = New MSForms.DataObject
DataObj.SetText oContact.Email1Address
DataObj.PutInClipboard


End Sub
 
Thanks so much....I tested it....there was an error...I took off one line as you will below and it works...as I copies the email addresss of the contact

Sub CopyEmailAddress()

Dim oContact As ContactItem

'DataObj As MSForms.DataObject
Set oContact = ActiveExplorer().Selection.Item(1)
Set DataObj = New MSForms.DataObject
DataObj.SetText oContact.Email1Address
DataObj.PutInClipboard

End Sub
 
Update re the If line for the email address?
 
I've looked at it quite a few times and can't see where there might be a mistake. It *should* work.
 
So what if line specifically for the email field please?
 
I have used the following code line with the words Email1Address and it says can find the object.....I have replaced with Email and E-mail and it does not work....same error. ifitem.getinspector.modifiedformpages("General").controls("Email1Address").text <> "" then txtEmailAddress = "E-Mail Address" & ": " & vbcrlf & item.getinspector.modifiedformpages("General").controls("Email1Address").text & vbcrlf
 
I added to the contact form, a new text field, which is TextBox29 and I copied to that text box in a contact, the email address of the contact, and used the If line you gave me to this TextBox29, and the txtEmailAddress equals the TextBox29, and then in the Calendar Event, the email shows up automatically as an email address. So, it might be that If line using the Email1Address does not work with the words .text so what can we change so it recognizes the Email1Address as an object...as the error is in can't find the object.
 
i noticed i looked at the code above earlier that you are looking for email1address - i don't think you can use controls to get defaults, only custom controls. That would explain why it didn't work...
 
It actually works for the other fields that I did not create....it works for FullName, Nickname, Company.....so these were not custom controls that I am aware of
 
No, they aren't. Oh, i bet its because the email address isn't a text field (text fields don't support hyperlinks).
 
S o can we change the If line to recognize the email field ? And if not, is there way to create a new text field that automaticaly fills in the text field the email address from the email field so it is a text field equal to the emai field?
 
I don't know what it is - the field is listed as a text field on the form. It's called E-mail in the field properties - have you tried using that?
 
Thank you. I did it and the error is "cannot find the specific object".....so again, what to change or also is there a way to create a text field that automatically has the words from the email field? And is what I tried again per what you said: if item.getinspector.modifiedformpages("General").controls("E-mail").text <> "" then txtEmailAddress = "E-Mail Address" & ": " & vbcrlf & item.getinspector.modifiedformpages("General").controls("E-mail").text & vbcrlf
 
i'm out of ideas. you could create a combination field that uses the email field - but i'm not sure that will work. See Step 5, down near the bottom for an example of what the field properties would look like.
 
I created combination field but it is not showing the email address in the contact
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Outlook 2007 Contact Form Code Not Working Using Outlook 20
M Updating VBA code from outlook 2007 to outlook 2010 Using Outlook 1
K Outlook 2007 Error Code 0x80040607 Using Outlook 10
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

Similar threads

Back
Top