Solved

Create an email form

Posted on 2008-06-24
3
1,197 Views
Last Modified: 2013-11-28
Hi,

Im trying to create an email form in my cutsomer contacts database.  The form includes a [To] field, a [message] field and a group of tick boxes which will allow the user to select PDF files to attach to the email.  I have a few question regarding this:

1) Does the form need to be linked to a table?  I don't really need to save the emails especially if i use outlook to send the email as they will be stored there in the sent folder.

2)My [Message] field on the form is a text box set to rich text format, however, how do i enable the return key so that it doesn't move to the next field but adds a carriage return instead?

3)This is the main one - how would i email from this form?  I have used email in access before, but mainly for inhouse emails/notifications.  how would i attach the checked PDF files to the email?

I know this is a lot to ask, and i'm not sure if it can be done at all.  I hope someone can point me in the right direction and i look forward to hearing from you.

Tom
0
Comment
Question by:d10u4v
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 21861811
d10u4v,

I can get this to work for Outlook 2003,

But the object model for Outlook changed in 2007.

I will try to test this at work tomorrow with Outlook 2007

JeffCoachman
0
 

Author Comment

by:d10u4v
ID: 21863547
HI,

I have been working on this myself and have been able to put together this code which works fine for check boxes on the form, but i am considering moving over to a list box which will be populated from a table which will store the full path and a description of the PDF file.  I'm unsure as to how to add the selected item from the list box to the .Attachements.Add of the code...

 
Private Sub cmdSend_email_Click()
 
        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)
            
            Set appOutLook = CreateObject("Outlook.Application")
            Set MailOutLook = appOutLook.CreateItem(olMailItem)
            With MailOutLook
            .BodyFormat = olFormatRichText
            .to = Me.email_address
            .Subject = Me.mess_subject
            .HTMLBody = Me.mess_text
            Dim ctrl As Control
For Each ctrl In Me.Controls
 If TypeOf ctrl Is CheckBox Then
        If ctrl.Value = -1 Then
               .Attachments.Add (ctrl.Tag)
        End If
 End If
Next
 
            '.DeleteAfterSubmit = True   'This would let Outlook send th note without storing it in your sent bin
            .Send
            End With
            'MsgBox MailOutLook.Body
            Exit Sub
email_error:
            MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
            Resume Error_out
Error_out:
End Sub

Open in new window

0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 21866466
d10u4v,

To select/Add Multiple attachments from a list box, use code similar to this:

http://www.tek-tips.com/viewthread.cfm?qid=1166066&page=1

JeffCoachman
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question