Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Apr 2007
    Location
    Lancashire, United Kingdom
    Posts
    264
    Thanks
    32
    Thanked 5 Times in 5 Posts

    Question I need the SMTP name from Outlook in Excel - anyone got some code?

    As the title says, I need the SMTP address from Outlook of the user running my code so I can 'CC' them when they email a message.

    I can do the email bit - but I can't work out how to get the SMTP address. I need that one because there are too many names in the GAL for me to guarentee a unique name from the "Office" name (which I can get).

    Does anyone have a code fragment that can help me? I have this:

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
    .....
    .....

    Thanks

    Alan

  2. #2
    3 Star Lounger
    Join Date
    Apr 2007
    Location
    Lancashire, United Kingdom
    Posts
    264
    Thanks
    32
    Thanked 5 Times in 5 Posts
    I found some code
    Dim objNS As Outlook.Namespace
    Set objNS = Outlook.GetNamespace("MAPI")
    msgbox objNS.Session.CurrentUser.AddressEntry.GetExchange User.PrimarySmtpAddress


    but that needs a reference to the object library added to all users (I think) and it also makes Outlook ask for permission to give the app the email address - which I don't want to do.

    So, I think I'll find another way.

    Alan

  3. #3
    3 Star Lounger
    Join Date
    Apr 2007
    Location
    Lancashire, United Kingdom
    Posts
    264
    Thanks
    32
    Thanked 5 Times in 5 Posts
    Just as an FYI, I found this section from MS http://msdn.microsoft.com/en-us/libr...m_members.aspx which proved very useful. So, rather than cc'ing the email to the originator, I ask for a delivery and read receipt and ensure the email is saved in "Sent Items". That does what I need (which was to provide an audit trail for the email).

    regards and I hope that helps others.

    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •