Results 1 to 3 of 3
  1. #1
    Rusty11 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    2

    Email to Drifferent languages out of access


    Hi guys

    Hopeing one of you could help me out
    i have a access database setup which i can email out of but it emails everyone with an address which is fine
    i have a language field in the database telling me what there prefered language is.

    now the question is can i make the code select a spefic file based on the language the person speaks
    or can i write code that says if (language field) is english send if not then dont?

    because then i can create different modules for each language, any help with this would be awesome

    Thanks
    Regards
    Rusty

  2. #2
    JeroenMioch's Avatar
    JeroenMioch is offline Competent Performer
    Windows Vista Access 2003
    Join Date
    May 2012
    Location
    Den Haag, Netherlands
    Posts
    368
    If me.language = "english" then
    ' do some sending out
    else
    exit sub 'outta here
    end if
    exit sub

    something like that ?

  3. #3
    Rusty11 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Posts
    2
    Sorry im pretty new to all this

    where in the code would i add that?
    i have inserted the code below, also how would i reference that to my database?

    Public Function SendEMail()
    Dim db As DAO.Database
    Dim MailList As DAO.Recordset
    Dim MyOutlook As Outlook.Application
    Dim MyMail As Outlook.MailItem
    Dim Subjectline As String
    Dim BodyFile As String
    Dim fso As FileSystemObject
    Dim MyBody As TextStream
    Dim MyBodyText As String
    Set fso = New FileSystemObject
    ' First, we need to know the subject.
    Subjectline$ = InputBox$("Please enter the subject line for this mailing.", "We Need A Subject Line!")
    ' If there??s no subject, call it a day.
    If Subjectline$ = "" Then
    MsgBox "No subject line, no message." & vbNewLine & vbNewLine & "Quitting...", vbCritical, "E-Mail Merger"
    Exit Function
    End If
    ' Now we need to put something in our letter...
    BodyFile$ = "C:\Users\Brad\Documents\Projects\test.txt"
    ' If there??s nothing to say, call it a day.
    If BodyFile$ = "" Then MsgBox "No body, no message." & vbNewLine & vbNewLine & "Quitting...", vbCritical, "I Ain??t Got No-Body!"

    ' Check to make sure the file exists...
    If fso.FileExists(BodyFile$) = False Then
    MsgBox "The body file isnt where you say it is. " & vbNewLine & vbNewLine & "Quitting...", vbCritical, "No-Body!"
    Exit Function
    End If
    ' Since we got a file, we can open it up.
    Set MyBody = fso.OpenTextFile(BodyFile, ForReading, False, TristateUseDefault)

    'and read it into a variable.
    MyBodyText = MyBody.ReadAll
    ' and close the file.
    MyBody.Close
    ' Now, we open Outlook for our own device..
    Set MyOutlook = New Outlook.Application
    ' Set up the database and query connections
    Set db = CurrentDb()
    Set MailList = db.OpenRecordset("E-mail")
    ' now, this is the meat and potatoes.
    ' this is where we loop through our list of addresses,
    ' adding them to e-mails and sending them.
    Do Until MailList.EOF
    ' This creates the e-mail
    Set MyMail = MyOutlook.CreateItem(olMailItem)
    ' This addresses it

    MyMail.To = MailList("email")
    'This gives it a subject
    MyMail.Subject = Subjectline$
    'This gives it the body
    MyMail.Body = MyBodyText
    'If you want to send an attachment
    'uncomment the following line
    'MyMail.Attachments.Add "c:myfile.txt", olByValue, 1, "My Displayname"
    ' To briefly describe:
    '"c:myfile.txt" = the file you want to attach'
    ' olByVaue = how to pass the file. olByValue attaches it, olByReference creates a shortcut.
    ' the shortcut only works if the file is available locally (via mapped or local drive)'
    ' 1 = the position in the outlook message where to attachment goes. This is ignored by most
    ' other mailers, so you might want to ignore it too. Using 1 puts the attachment' first in line.'
    ' "My Displayname" = If you don??t want the attachment??s icon string to be "c:myfile.txt" you' can use this property to change it to something useful, i.e. "4th Qtr Report"
    'This sends it!
    'MyMail.Send
    'Some people have asked how to see the e-mail
    'instead of automaticially sending it.
    'Uncomment the next line
    'And comment the "MyMail.Send" line above this.
    MyMail.Display
    'And on to the next one...
    MailList.MoveNext
    Loop
    'Cleanup after ourselves
    Set MyMail = Nothing
    'Uncomment the next line if you want Outlook to shut down when its done.
    'Otherwise, it will stay running.

    MyOutlook.Quit
    Set MyOutlook = Nothing
    MailList.Close
    Set MailList = Nothing
    db.Close
    Set db = Nothing

    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 04-13-2011, 10:11 AM
  2. access to email
    By cecrotty in forum Access
    Replies: 4
    Last Post: 02-05-2011, 03:49 PM
  3. Decimal seperator between different languages
    By seshan in forum Programming
    Replies: 3
    Last Post: 01-31-2010, 03:03 PM
  4. Replies: 1
    Last Post: 09-29-2009, 04:34 AM
  5. Please help w/ simple languages db
    By TalentNation.net in forum Database Design
    Replies: 0
    Last Post: 01-23-2009, 09:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums