Results 1 to 7 of 7
  1. #1
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Email Code Help (2000)

    I have a form with customer information that I would like to e-mail to my insurance agent. The customer information resides in the form where the command button is (to send the e-mail msg), and the insurance agent info (name and e-mail address) resides in a separate table with my company information. Aside from the fact that my code doesn
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

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

    Re: Email Code Help (2000)

    Does your tblCompanyInfo table contain a single record, or can it contain multiple records? If the latter, how can Access determine which record to use?

  3. #3
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email Code Help (2000)

    Hans:

    It's a single record with the company address and contact info (used primarily to include in report headers). I put the insurance contact info there also. That way, if it changes, I only have one place to make the edit.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

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

    Re: Email Code Help (2000)

    OK, that's what I hoped. Try this:

    Private Sub cmdSendAIEmail_Click()
    Dim strRecipient As String
    Dim strSubject As String
    'Dim strContact As String
    Dim strMessage As String
    strRecipient =Nz(DLookup("txtUSCSInsAgentEmail", "tblCompanyInfo"), "")
    If strRecipient = "" Then
    MsgBox "No e-mail ", vbCritical
    Exit Sub
    End If
    strSubject = "Additionally Insured Certificate Request"
    'strContact =DLookup("txtUSCSInsAgentContact", "tblCompanyInfo") & vbCrLf & vbCrLf
    strMessage = "This is to request an Additionally Insured Certificate for: " & vbCrLf & _
    Me.txtCustName & vbCrLf & Me.txtCustCertAdr & vbCrLf & _
    Me.txtCustCertCity & ", " & Me.txtCustCertState _
    & " " & Me.txtCustCertZip & vbCrLf & _
    "Fax: " & Me.txtCustCertFax & vbCrLf & "Email: " & Me.txtCustCertEmail & _
    vbCrLf & vbCrLf & "Thank You," & vbCrLf & "Operations Manager" & _
    vbCrLf & "Company Name"
    DoCmd.SendObject , , , strRecipient, , , strSubject, strMessage
    End Sub

    I have commented out the code for strContact since it isn't clear to me what that is used for (SendMail is not an existing Access instruction, so I can't guess)

  5. #5
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email Code Help (2000)

    Hans:

    Thanks for the help Hans; you're getting really good at reading Bryanese <img src=/S/smile.gif border=0 alt=smile width=15 height=15> I
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

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

    Re: Email Code Help (2000)

    Try this then (yes, you can ignore the 2501 error safely - see the error handler)

    Private Sub cmdSendAIEmail_Click()
    Dim strRecipient As String
    Dim strSubject As String
    Dim strMessage As String

    On Error GoTo ErrHandler

    strRecipient =Nz(DLookup("txtUSCSInsAgentEmail", "tblCompanyInfo"), "")
    If strRecipient = "" Then
    MsgBox "No e-mail ", vbCritical
    Exit Sub
    End If
    strSubject = "Additionally Insured Certificate Request"
    strMessage = DLookup("txtUSCSInsAgentContact", "tblCompanyInfo") & ":" & _
    vbCrLf & vbCrLf & _
    "This is to request an Additionally Insured Certificate for: " & vbCrLf & _
    Me.txtCustName & vbCrLf & Me.txtCustCertAdr & vbCrLf & _
    Me.txtCustCertCity & ", " & Me.txtCustCertState _
    & " " & Me.txtCustCertZip & vbCrLf & _
    "Fax: " & Me.txtCustCertFax & vbCrLf & "Email: " & Me.txtCustCertEmail & _
    vbCrLf & vbCrLf & "Thank You," & vbCrLf & "Operations Manager" & _
    vbCrLf & "Company Name"
    DoCmd.SendObject , , , strRecipient, , , strSubject, strMessage
    Exit Sub

    ErrHandler:
    If Not Err = 2501 Then ' ignore canceling the e-mail
    MsgBox Err.Description, vbExclamation
    End If
    End Sub

  7. #7
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email Code Help (2000)

    PERFECT!!
    Thanks Hans. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

Posting Permissions

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