Access / Outlook automation (newbie) - Programmers Heaven

Howdy, Stranger!

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

Categories

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 = "[email protected]"
    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.