Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397

    Unanswered: Help Required On Send Email Code Error

    Hi,

    I want to send snapshot report by email (Microsoft Outlook) to some specific people. I normally open db (MDB) and see report then right click on report that produce pop up menu from where I select send to ...Mail Receipant as attachment...(snapshot format)

    I know this is not good practise. The Codeline below I got from some other forum produce errors

    Do anyone have idea how can it open my Microsoft Outlook autmatically and send my snapshot report after clicking one button on the form?

    Public Sub Send(recipients As String, from As String, subject As String, smtpServer As String, Optional msg As String, Optional attachPath As String)
    On Error GoTo handler
    Dim iMsg As New CDO.Message
    Dim iConf As New CDO.Configuration

    With iConf
    With .Fields
    .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpServer
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous
    .Update
    End With
    End With

    With iMsg
    Set .Configuration = iConf
    .To = recipients
    .from = from
    .subject = subject
    If msg <> "" Then .TextBody = msg
    If attachPath <> "" Then .AddAttachment attachPath
    .Send
    End With

    Set iMsg = Nothing
    Set iConf = Nothing
    Exit Sub

    handler:
    Err.Raise Err, Err.Source & " - Lib.Mail.Send()"
    End Sub

    I already have set CDO ref.

    The other code behind a button on form is :

    Private Sub CmdSendToDesp_Click()
    Send _
    "Tamer@sls.net;ashfaque@sls.net", _
    "ashfaque@sls.net", _
    "This is the Subject Line", _
    "smtp.1and1.com", _
    "To Whom It May Concern:" & vbCrLf & _
    " This is the body text of the email." & vbCrLf & _
    "Sincerely, " & vbCrLf & _
    "lag", _
    "C:\test.snp"
    End Sub

    I am sure I am wrong somewhere......I want to send the current report and send it by email....but it produces attached error. Can someone help please.....
    Attached Thumbnails Attached Thumbnails Send Mail Code Error.JPG  
    With kind regards,
    Ashfaque

  2. #2
    Join Date
    Jan 2005
    Location
    Nanded, India
    Posts
    397

    Thumbs up I got it but one advancement need....

    Hi Guys,

    I got very simple and good code instead of above lengthy one.

    Dim strMailList As String
    strMailList = "cris@surelevelsaudia.net;"

    DoCmd.SendObject acSendReport, "R_RequiredMaterial_A", acFormatSNP, strMailList, , , "NEW DELIVERY - " & _
    Format(Now()), "Cris," & vbCr & vbCr & "Please arrange delivery as per attached." & vbCr & vbCr & "Thanks" & _
    vbCr & vbCr & "My Name Here.." & vbCr & "Administrator", True, Signa

    This works simply great. It opens Microsoft Outlook, attach my report in snapshot and ready for send.

    I am looking 2 more thing here.

    1. I want to add my signature before I send it. I tried in below way but doesn't work.

    Dim Signa As String

    Signa = "C:\Documents and Settings\admin\Application Data\Microsoft\Signatures\13.rtf"

    DoCmd.SendObject acSendReport, "R_RequiredMaterial_A", acFormatSNP, strMailList, , , "NEW DELIVERY - " & _
    Format(Now()), "Cris," & vbCr & vbCr & "Please arrange delivery as per attached." & vbCr & vbCr & "Thanks" & _
    vbCr & vbCr & "My Name Here.." & vbCr & "Administrator", True, Signa

    2. I want to set my email (thru above code) in html format not Plaint Text format. How can I do that ?

    With kind regards,

    Anyony have idea how to automatically add my signture (template file)
    With kind regards,
    Ashfaque

  3. #3
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    There's also some email coding examples in the code-bank.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

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