1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Access VBA For Email

Discussion in 'Business Applications' started by karlhaywood, Jan 3, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. karlhaywood

    karlhaywood Account Closed Thread Starter

    Joined:
    Jan 17, 2010
    Messages:
    680
    Hi,

    I have created a form and want to be able to email the record that is on screen, can anyone help me with this.

    These are the text boxes on the form:

    Task Name
    Assigned To
    Expected completion date
    Description of task

    These 2 are in no table or query.
    Recipient
    Subject
     
  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Karl, you should be able to use a modified version of one of the codes on the form in the attached database.
    I think you may already have a copy though.
     

    Attached Files:

  3. karlhaywood

    karlhaywood Account Closed Thread Starter

    Joined:
    Jan 17, 2010
    Messages:
    680
    I probably do have a copy, but it would be stored on my external hard drive and it packed up lol. I will try this and get back to you.
     
  4. karlhaywood

    karlhaywood Account Closed Thread Starter

    Joined:
    Jan 17, 2010
    Messages:
    680
    OBP i have this code below, Could you help me alter this? The reason i would prefer to use this is that the database will be on 4 different machines so when sending an email it will be from the email address being used on that machine.
     
  5. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    You didn't show any code. The code that I used on that form normally uses the mailing program on the users computer.
     
  6. karlhaywood

    karlhaywood Account Closed Thread Starter

    Joined:
    Jan 17, 2010
    Messages:
    680
    I know, but you have to enter an email address in the code, the email address will be different on every machine. Here is the code.

    Private Sub SendMailBttn_Click()
    'Open an instance of microsoft outlook, name it olk.
    Dim olk As Outlook.Application
    Set olk = CreateObject("Outlook.application")
    'Create a new, empty outlook e-mail message
    Dim olkMsg As Outlook.Mailitem
    Set olkMsg = olk.Createitem(olMailitem)
    'Put data from form into the new message
    With olkMsg
    Dim OlkRecip As Outlook.Recipient
    Set OlkRecip = .Recipients.Add(Me![MsgAddress])
    OlkRecip.Type = olTo
    .subject = Me![MsgSubject]
    .Body = Me![MsgBody]
    .Send
    End With
    Set olk = Nothing
    Set olkMsg = Nothing
    Set OlkRecip = Nothing
    End Sub
     
  7. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    You only have to do the same as that code and have a Recipient field on the form.
     
  8. karlhaywood

    karlhaywood Account Closed Thread Starter

    Joined:
    Jan 17, 2010
    Messages:
    680
    Not the recipient, the email address of where the email is being sent from!
     
  9. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    You shouldn't need to do that at all, Outlook default should do it.
     
  10. karlhaywood

    karlhaywood Account Closed Thread Starter

    Joined:
    Jan 17, 2010
    Messages:
    680
    Ok OBP i will take a look at ur sample. Thanks.
     
  11. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/972386

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice