Results 1 to 11 of 11
  1. #1
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Assigning From Field (2003/Access)

    Morning...

    My Outlook has multiple project Inboxes that I am a part of. I am creating an email from an access database that I want the "From" field to be one of the project emails and not my personal email.

    I have everything working with regards to creating the email To:, Bcc:, Subject and Body...but I cannot get it to recognize the project email address.

    Is there a way thru vba that I can assign which Inbox to use?

    Thank you!

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    You can use the SentOnBehalfOfName property if the Mailitem to set another From than your personal.
    Something like this :
    <pre>myMailItem.SentOnBehalfOfName = "Jules@net.be"</pre>

    Francois

  3. #3
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    I am still getting an Object Required error message...

    here is my code as it stands...am I missing something in code or does it have to do with my Outlook?

    Dim myOlApp, myItem, myAttachments, myRecipient, olMailItem, myFromAddress
    Dim SentOnBehalfOfName
    Dim appOutlook As Outlook.Application
    Dim MailOutlook As Outlook.MailItem

    Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.CreateItem(olMailItem)
    Set myAttachments = myItem.Attachments
    Set myRecipient = myItem.Recipients.Add(Me.CONTACT_EMAIL)
    Set myItem.SentOnBehalfOfName = "email_address@email.com"

    With myItem
    .To = myRecipient

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    Change your code as follow:
    <pre>Dim myOlApp, myItem, myAttachments, myRecipient, olMailItem, myFromAddress
    Dim SentOnBehalfOfName
    Dim appOutlook As Outlook.Application
    Dim MailOutlook As Outlook.MailItem

    Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.CreateItem(olMailItem)
    Set myAttachments = myItem.Attachments

    With myItem
    .SentOnBehalfOfName = "email_address@email.com"
    .To = Me.CONTACT_EMAIL</pre>

    You can also remove the line
    Set myAttachments = myItem.Attachments
    if you want, as this line do nothing
    Francois

  5. #5
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    Thanks!

    That did work.

    at some point I am going to be attaching docs...that's a place holder for now.

    Have a great day!

  6. #6
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    one other thing...

    Its putting the message in the Sent Folder of my default Inbox and not the project inbox.

    Is there an easy way to do this thru code or is this something I should setup in my Outlook rules?

  7. #7
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    Sent-Folder...

    Its putting the message in the Sent Folder of my default Inbox and not the project inbox.

    Is there an easy way to do this thru code or is this something I should setup in my Outlook rules?

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    Add the two Italic lines to your code.
    Don't forget to change Personal Folders, Inbox and MyFolder with the name you use.
    <pre>Dim myOlApp, myItem, myAttachments, myRecipient, olMailItem, myFromAddress
    Dim SentOnBehalfOfName
    Dim appOutlook As Outlook.Application
    Dim MailOutlook As Outlook.MailItem

    Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.CreateItem(olMailItem)
    Set myAttachments = myItem.Attachments
    Set fldr = myOlApp.GetNamespace("MAPI").Folders("Personal" & _
    " Folders").Folders("Inbox").Folders("MyFolder")
    Set myItem.SaveSentMessageFolder = fldr


    With myItem
    .SentOnBehalfOfName = "email_address@email.com"
    .To = Me.CONTACT_EMAIL</pre>

    Francois

  9. #9
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    I am receiving this errror - "The Operation Failed. An Object could not be found." I did create a personal "Test" folder for this account under the Inbox. I guess I'm not quite sure about the naming on the Inbox...is this the name of the email address? I cannot change the Inbox name. Thanks for your patience...

    Here is my code as it stands...

    Dim MailOutlook As Outlook.MailItem
    Dim myOlApp, myItem, myAttachments, myRecipient, olMailItem, appOutlook As Outlook.Application
    Dim SentOnBehalfOfName
    Dim Fldr
    'Dim myBCCRecipient

    Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.CreateItem(olMailItem)
    Set myAttachments = myItem.Attachments
    Set myRecipient = myItem.Recipients.Add(Me.CONTACT_EMAIL)

    Set Fldr = myOlApp.GetNamespace("MAPI").Folders("Personal" & " Folders").Folders("Inbox").Folders("Test")
    Set myItem.SaveSentMessageFolder = Fldr

    With myItem
    .SentOnBehalfOfName = "reliabilityproject@companyemail.com"
    .To = myRecipient

    myItem.SUBJECT = PROJECT_TEXT & " " & SUBJECT & " (Contact ID: " & CONTACT_ID_TEXT & ")"
    'myAttachments.Add txtFULL_PATH

    myItem.Body = OPENING & vbNewLine & RESPONSE_TEXT & vbNewLine & CLOSING

    myItem.Display

    End With

  10. #10
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    If you write the first line in one line, then you should use :
    Set Fldr = myOlApp.GetNamespace("MAPI").Folders("Personal Folders").Folders("Inbox").Folders("Test")

    For the inbox you have to use the tree you have in outlook. See attachment (picture of my outlook)
    Attached Images Attached Images
    Francois

  11. #11
    Star Lounger
    Join Date
    Oct 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Assigning From Field (2003/Access)

    That did it...thanks for your help!

    Steve

Posting Permissions

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