try again email forms

R

Ruth

Hi there

I have searched for the codes to email a form/report in a body of an email
and have Access connect to MS outlook to choose who to email to. I have
tried several different codes and do not understand code. None of the ones
that I have tried worked. The last one I have tried is:

Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
'MsgBox (mess_body)
mess_body = "The following Enrollment Form Order requires your approval: " &
Me.Order_ID.Value
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
..To = " email@removed "
..CC = " email@removed "

Can someone help me with the code, let me know what I need to do to make it
work, or point me to a website with code that may do the trick. There maybe
something in the code that I need to change to match up with my setup, but I
am clueless when it comes to code. Maybe there is a good book out there that
I can buy? Please let me know.
 
R

Ruth

Hi again

I link the address in Outlook to Access, called the table "EmailClient" and
tried the following code and get a message box that says "You canceled the
previous operation" Is there anything I can to to fix it?

Dim EmailClient As Variant
Dim stAppName As String
Dim ClientName As String

On Error GoTo Err_btnEmail_Click

‘ Look up the base directory of the e-mail client in table EmailClient
EmailClient = Trim(DLookup("OutLookAddress", "EmailClient"))
If IsNull(EmailClient) Then
' Open a simple form asking the user to enter the base directory
DoCmd.OpenForm "EmailClient", , , , acFormAdd
Else
If Not IsNull(Me!ContactEmail) And Not IsNull(EmailClient) Then
' if there is a \ on the end remove it
If InStr(Len(EmailClient), EmailClient, "\") Then
EmailClient = Left(EmailClient, Len(EmailClient) - 1)
End If
‘ add the outlook client, set the command line options, add the form
address
stAppName = EmailClient & "\outlook.exe /c ipm.note /m " &
Me!ContactEmail
‘ Launch Outlook
Call Shell(stAppName, 1)
Else
MsgBox "The Email Client or Email Address is Null, please enter it"
End If
End If
Exit_btnEmail_Click:
Exit Sub

Err_btnEmail_Click:
MsgBox Err.Description
Resume Exit_btnEmail_Click
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top