-1

I followed the below example.

https://www.slipstick.com/developer/create-a-new-message-using-vba/

I want to display address book name when automatically making the email draft.

For example, in this case,

I am able to display "BZ@gmail.com" in the address field but I want to display an address book's name "Business Team" because "Business Team" is easier to see.

Here is my code. it is almost same as the example code.

Public Sub CreateNewMessage()
Dim objMsg As MailItem

Set objMsg = Application.CreateItem(olMailItem)

With objMsg
  .To = "Alias@domain.com"
  .CC= "Alias2@domain.com"
  .BCC = "Alias3@domain.com"
  .Subject = "This is the subject"
  .Categories = "Test"
  .VotingOptions = "Yes;No;Maybe;"
  .BodyFormat = olFormatPlain ' send plain text message
  .Importance = olImportanceHigh
  .Sensitivity = olConfidential
  .Attachments.Add ("path-to-file.docx")

 ' Calculate a date using DateAdd or enter an explicit date
  .ExpiryTime = DateAdd("m", 6, Now) '6 months from now
  .DeferredDeliveryTime = #8/1/2012 6:00:00 PM#

  .Display
End With

Set objMsg = Nothing
End Sub

I can send only by "alisas@domain.com" and when I see the opened draft, email address displayed.

How can I display address book name on draft?

Community
  • 1
  • 1
박영종
  • 119
  • 1
  • 2
  • 8
  • If **Business Team** is in the GAL under Exchange environment, Outlook tries to resolve names after a certain time. There is no *MsgBox* in codes by your link, so what is your code? Add your code by Edit your post. – PatricK Dec 10 '17 at 23:42
  • 1
    don't mind msgbox... I just mean... I dont want answers that uses msgbox. in my code there are no msgbox. – 박영종 Dec 11 '17 at 01:40
  • 1
    I'll upload my code, wait a minute – 박영종 Dec 11 '17 at 01:40
  • You may have to use [`MailItem.Recipients.Add`](https://msdn.microsoft.com/en-us/VBA/Outlook-VBA/articles/recipients-add-method-outlook) to use the Display Name instead of SMTP address. – PatricK Dec 11 '17 at 06:23
  • 1
    Wow you are great! – 박영종 Dec 11 '17 at 08:33
  • 1
    Thank you... but how can I add CC by address name..? – 박영종 Dec 11 '17 at 11:00

1 Answers1

-1

For the first part of your question, refer to Recipients.Add Method (Outlook).

For CC's, you need to change the recipient type, see answer for this SO question.

PatricK
  • 6,375
  • 1
  • 21
  • 25