Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    10

    Unanswered: Help with syntax

    The following is part of a function to send an email from a form:

    With oMessage
    .Importance = olImportanceHigh 'High importance
    .To = [Forms]![DataEntry]![EmailAddress]
    .Subject = [Forms]![DataEntry]![Type]
    .Body = ??????
    .Send
    End With

    In the body of the email I want to include the contents of various controls in the same way that the subject of the email contains the value of [Forms]![DataEntry]![Type], but I would also like the body to contain free text and new lines.

    Any ideas?

    Many thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    UK
    Posts
    68
    It can be done quite easily but by design it will not be very flexible. How structured in layout is the body likely to be ??

  3. #3
    Join Date
    Dec 2003
    Posts
    10
    I want to be like a standard letter.

    So it will be something like:

    [Forms]![DataEntry]![Salutation](space)[Forms]![DataEntry]![FirstName](space)[Forms]![DataEntry]![Surname](new line)


    [Forms]![DataEntry]![Address1](newline)
    [Forms]![DataEntry]![Address2]
    etc.

    eg:

    Mr John Doe
    Main St.
    London.

    I expect all would align left by default.

    Thanks Funkster.

  4. #4
    Join Date
    Jun 2003
    Location
    UK
    Posts
    68
    With oMessage
    .Importance = olImportanceHigh 'High importance
    .To = [Forms]![DataEntry]![EmailAddress]
    .Subject = [Forms]![DataEntry]![Type]
    .Body = [Forms]![DataEntry]![Salutation] & " " & [Forms]![DataEntry]![Salutation] & " " & [Forms]![DataEntry]![Su
    rname] & vbCrLf & [Forms]![DataEntry]![Address1] & vbCrLf & [Forms]![DataEntry]![Address2]
    .Send
    End With

    You can use the & to concantenate a string and the carriage return funtion vbCrLf to input a new line. The space is provided by concatenating a space using " " . If you play about with the above it should do what you need.

    NB I have not placed any string line breaks in the above so you will need to ensure the string is all on one line.

  5. #5
    Join Date
    Dec 2003
    Posts
    10
    Thanks a million Funkster.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •