Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with email automation

Status
Not open for further replies.

patrichek

MIS
Nov 18, 2003
632
US
Hi, I used the code from this thread to setup and auto email from a table in access. thread707-659279

i'm having a problem with this area
Code:
strEmail = rst("Email")
      strbody = vbCrLf & vbCrLf & _
                "put the text you want in your email here"

the problem is that it seems the amount of text i can input for the body of the email is limited?
Does anyone know how I can change this to make it work with a whole page of text?

thanks!
 
What is the code that you are actually running? If you run the code that you posted, then it looks like every email will have a body of "put the text you want in your email here". Do you get an error? If so what is the error?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
hi, no error. It won't let me put the amount of text i need in the "Put the text you want in your email here"
I'm only allowed 1 line of text and i have a whole page.
sry, i'm very green at coding!

here's my whole code:
Code:
Function SendMail()
    
    Dim dbs      As DAO.Database
    Dim rst      As DAO.Recordset  
    Dim strSQL   As String        
    Dim strEmail As String       
    Dim strbody  As String
    
    ' Return reference to current database.
    Set dbs = CurrentDb
    'Find record to send report of
    strSQL = "SELECT Name, Email " & _
             "FROM Email"
    
    Set rst = dbs.OpenRecordset(strSQL)
    
Do While Not rst.EOF
    
  strEmail = ""
Do While Not rst.EOF
      strEmail = strEmail  & rst("Email") & ";" 
      rst.MoveNext
Loop
      strEmail = left(strEmail,len(strEmail)-1)
      strbody = vbCrLf & vbCrLf & _
                "put the text you want in your email here"

    ' send email.
    DoCmd.SendObject acSendNoObject, "", acFormatTXT, strEmail, , , strHP, strbody, False

thanks!
btw, i'm sending a form letter to a table full of email addresses.
 
I suspect the most straightforward way would be to store the text that you want for the body in a text file the open the textfile, set the text in it = to a variable and use that variable instead of "put the text you want in your email here". You can find lots of examples of opening and reading text files by searching this forum.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
thanks Ed!
I decided to try this approach:

strbody = "Line 1" & vbCrLf & "Line2"

Then my e-mail would look like:

Line1
Line2
 
That will work although it will get annoying with more than about 2 lines of text. Also, with the external textfile method, whenever you want to change the body of the email you don't have to actually change the code, you just change the text file. Seperating the data layer from the computation layer is rarely a bad thing.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
i'm really a newbie here so can you give me an example of how the code would look for external txt file?

thanks!
 
thanks for the responses. since i'm such a newbie could you show me an example of the code that i could use for an external txt file?
thanks again!
 
Near the top of this page is a button labelled "Search". Click that button. A new page will open. On that page will be a text field labeled "Keyword(s)". In this field type 'read text file' without the quotes and click the button labelled "Search!" near the bottom of the page. You will get lots of examples.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top