Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Access / Outlook automation (newbie)

hazydavyhazydavy Posts: 3Member
I want to open a new Outlook email message from within Access 2003 code, insert the To address (from an active form) and then allow the user to type a subject and the email body. I can generate and send an entire message automatically, but I can't work out how to simply open a new mail item and then let the user do the rest.

Any pointers would be greatly appreciated - I'm new to Office apps interoperability, and it's a hard slog trying to learn from MSDN website.

Also, any recommended books on cross-office programming?

Many thanks.

Comments

  • JomacJomac Posts: 231Member
    : I want to open a new Outlook email message from within Access 2003 code, insert the To address (from an active form) and then allow the user to type a subject and the email body. I can generate and send an entire message automatically, but I can't work out how to simply open a new mail item and then let the user do the rest.
    :
    : Any pointers would be greatly appreciated - I'm new to Office apps interoperability, and it's a hard slog trying to learn from MSDN website.
    :
    : Also, any recommended books on cross-office programming?
    :
    : Many thanks.
    :

    First you need to reference the MSOutlook Object Library, then;
    [code]
    Dim OLApp As Outlook.Application
    Set OLApp = GetObject("", "Outlook.Application")
    With OLApp.GetNamespace("MAPI").GetDefaultFolder(olFolderDrafts).Items.Add()
    .To = "someone@somewhere.here"
    Call .Display
    End With
    [/code]
    This code does no error handeling so you would need to make sure outlook did what it was told.
    ______
    [size=2][b][blue]J[/blue]omac.[/b][/size]

Sign In or Register to comment.