Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Email address with 's (Access 2003)

    I would like to send an email to the following address (WC RAM's@shop) with code. I'm having problems with the 's and or space and when the email goes out it goes to WC. How do I change the code to deal with the space and 's The code I use is:

    Set DivEmail = rs![EmailBH]
    DoCmd.SendObject acTable, MstrTbl, "MicrosoftExcelBiff8(*.xls)", DivEmail, "", "", strEmailHeader, , False, ""

    TIA

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email address with 's (Access 2003)

    I thought spaces weren't allowed in an e-mail address, but anyway, does it work if you use

    Chr(34) & DivEmail & Chr(34)

    Question: why do you use Set in the line that assigns a value to DivEmail?

  3. #3
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email address with 's (Access 2003)

    After your statement about spaces not allowed I realized that I am showing the name as it appears on our company's address book. I will change the email address the RAM's@shop as it appears under the email properties.

    The set I've done as per code I copied. What is the right way to do it? Here is the complete code for that section:

    Set DB = CurrentDb
    Set rs = DB.OpenRecordset(EmailTbl, dbOpenDynaset)
    Set DivisionName = rs![DivName]
    Set DivEmail = rs![EmailBH]

    DoCmd.OpenTable MstrTbl, acNormal, acReadOnly
    DoCmd.SelectObject acTable, MstrTbl, False
    Do While rs.EOF = False
    DoCmd.ApplyFilter "", "[" & MstrTbl & "]![DivName]=" & Chr(34) & DivisionName & Chr(34)
    DoCmd.SendObject acTable, MstrTbl, "MicrosoftExcelBiff8(*.xls)", DivEmail, "", "", strEmailHeader, , False, ""
    rs.MoveNext

    Loop
    DoCmd.Close acTable, MstrTbl, acSaveNo

    Thanks

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email address with 's (Access 2003)

    How are DivisionName and DivEmail declared, i.e. Dim DivisionName As ... ? Or don't you declare them at all?

  5. #5
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email address with 's (Access 2003)

    No I don't. What is the right method/code

    TIA

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email address with 's (Access 2003)

    See <post:=314,748>post 314,748</post:> for an explanation why you should always declare variables explicitly.

    In this case, the division name and e-mail are text strings, so I'd use

    Dim DivisionName As String
    Dim DivEmail As String

    The keyword Set is only used for object variables such as a Recordset or a Form, not for strings, numbers etc. So you'd assign values like this:

    DivisionName = rs![DivName]
    DivEmail = rs![EmailBH]

  7. #7
    3 Star Lounger
    Join Date
    Aug 2001
    Location
    Cape Town, South Africa, South Africa
    Posts
    399
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email address with 's (Access 2003)

    Thanks Hans.

Posting Permissions

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