Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to populate TO line with a custom prompt (Outlook 2000 & VBA 6.3)

    I want a button to appear on an email toolbar that when pressed will prompt the user for 3 values and enter them into the TO line of the email in a certain format.

    I've got the input box code and correct format to be stored in a string. Here's the code:
    <font color=blue>strFaxNumber = InputBox("Enter the fax number", "Enter Fax Number")
    strName = InputBox("Who are you sending the fax to?", "Enter Name")
    strCompany = InputBox("What company are you sending the fax to?", "Enter Company")
    strFaxFormat = "[EskerFax:" & strFaxNumber & "@" & strName & "@" & strCompany & "]"
    </font color=blue>

    So how do I assign the last string value (strFaxFormat) to the TO: line of the open email?

    something like this, I'm guessing, but I don't know what the correct properties are...

    <font color=blue> Outlook App.CurrentEmail.ToLine = strFaxFormat</font color=blue>

    Thanks.

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: How to populate TO line with a custom prompt (Outlook 2000 & VBA 6.3)

    Not tested, but the in the VBA model (CDO, Redemption and other library models are different) the To line has to be populated by Recipients, so the syntax is going to be more like:

    With Outlook App
    Set myMessage = .CreateItem(olMailItem)
    With myMessage
    .Recipients.Add = strFaxFormat
    .Recipients.Resolve

    HTH.
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to populate TO line with a custom prompt (Outlook 2000 & VBA 6.3)

    Hi, thanks for replying.

    Close, but no cigar.

    I added this:
    <font color=4682b4> Dim oOutlookApp As Outlook.Application
    Dim oMailItem As Outlook.MailItem

    'Instantiate top-level
    'application object:
    Set oOutlookApp = New Outlook.Application

    'create the mail item
    Set oMailItem = oOutlookApp.CreateItem(olMailItem)

    'set up the recipient:
    oMailItem.Recipients.Add (strEskerFaxFormat)
    oMailItem.Display
    </font color=4682b4>

    But it adds the string to a new email. I want to add it to the blank email I already have open. So I figure I have to change this line:
    Set oMailItem = oOutlookApp.CreateItem(olMailItem)

    to refer to the existing email I have open.

    I will make a button available on the new email form and assign this macro I'm creating. So the user will click this button on the blank email he already has open.

    Sarah

  4. #4
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: How to populate TO line with a custom prompt (Outlook 2000 & VBA 6.3)

    Hey, I said it was untested. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> With the the VBA Outlook Object Model (as opposed to other libraries), if you already have a message open, you get to it via Inspectors, and you may have a problem if multiple Outlook Items are open and the user messes about. (Outlooks' Object Model is just weird in this regard, and this is why I'd instantiate a new MailItem for the user.) Something like, again untested, air code, no cigar expected:

    Dim objItem as Object
    If CBool(Inspectors.Count) Then Set objItem = ActiveInspector.CurrentItem
    If Not objItem is Nothing And objItem.Class = olMail Then
    ... go for it
    -John ... I float in liquid gardens
    UTC -7ąDS

  5. #5
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to populate TO line with a custom prompt (Outlook 2000 & VBA 6.3)

    I figured it out.

    I changed this line:
    Set oMailItem = oOutlookApp.CreateItem(olMailItem)

    to this line:
    Set oMailItem = oOutlookApp.ActiveInspector.CurrentItem

    And it works.

    If someone sees a problem with using this code, please let me know. But I'm happy for now!

    Sarah

  6. #6
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: How to populate TO line with a custom prompt (Outlook 2000 & VBA 6.3)

    Light that cigar.
    -John ... I float in liquid gardens
    UTC -7ąDS

  7. #7
    2 Star Lounger
    Join Date
    Jul 2002
    Location
    North Dakota, USA
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: How to populate TO line with a custom prompt (Outlook 2000 & VBA 6.3)

    Thanks for the warnings, I'll give it a try.

    I take it the CBool function counts the number if items open? I haven't used that function before...

    sarah

  8. #8
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: How to populate TO line with a custom prompt (Outlook 2000 & VBA 6.3)

    CBool is a standard VB Type Converter which turns any non-zero number to TRUE and zero to FALSE, see the VB Help. It's not necessary, I just use it to document, like using the name of an intrinsic Constant rather than the value. Since you are going to attach the button to a new message, some of the error-checking may be unnecessary.
    -John ... I float in liquid gardens
    UTC -7ąDS

Posting Permissions

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