Results 1 to 5 of 5

Thread: email pdfs

  1. #1
    Join Date
    Jun 2002

    Unanswered: email pdfs

    Sorry if this has been asked a bunch of times already. I couldn't find anything specific to my question.

    I'm using the following code to open a pdf:

    Using Application.FollowHyperlink Me![Text39]

    [text39] is simply the path name. This is working great. The actual file name that is part of the path name equals the records autonumber field name, so it's quite easy to reference them.

    Now is there a way to email this same pdf file using a similar setup but with the sendobjects command? I'd also like to be able to send multiple attached pdf's if necesary. If anyone knows of the most simplest way of doing this please let me know. Thanks.

  2. #2
    Join Date
    May 2003
    Provided Answers: 5
    sendobject was basically disabled in sr1 versions and later of 2k
    programatically sending email from apps will now give a message that another app is accessing your email

    try this using the cdo object library - obviously you will have to substitute some of the example but I am sure you will get the picture

    Public Sub procCDOMail()
    Dim iMsg As CDO.Message
    Dim iConf As CDO.Configuration
    Dim Flds

    Set Flds = iConf.Fields

    With Flds
    .Item(cdoSendUsingMethod) = cdoSendUsingPort
    .Item(cdoSMTPServer) = "" ' your smtp server
    .Item(cdoSMTPConnectionTimeout) = 10 'Quick timeout
    .Item(cdoSMTPAuthenticate) = cdoBasic
    .Item(cdoSendUserName) = "sender name"
    .Item(cdoSendPassword) = "" 'if needed

    End With

    With iMsg
    Set .Configuration = iConf
    .To = "the email address "
    .From = ""
    .Subject = "This is a test."
    '.CreateHTMLBody "http://MyPage"
    .AddAttachment "C:\Autoexec.bat"
    End With

  3. #3
    Join Date
    Jun 2002
    Will this code work with Office 97?

  4. #4
    Join Date
    May 2003
    Provided Answers: 5
    if you get the correct cdo.dll it should (italics)

    I have some good sendmessage code using the outlook object model

  5. #5
    Join Date
    May 2003
    Provided Answers: 5
    here is code that works in 2000 using the outlook object model for 2000

    you should be able to use the outlook 8.0 object model without a problem

    Sub SendMessage(Optional AttachmentPath)
    On Error GoTo mymailerror
    Dim fs As FileSystemObject
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment
    Dim strconemail As String

    'This dim statement gets the email address from a table that matches the id on my form
    strconemail = DLookup("[email]", "tblconmaster", _
    "conid = forms!frmrange!conid")
    Dim mysubject As String
    Set fs = New FileSystemObject

    mysubject = "Any thing you want"

    mypath = "C:\pdf\" & Forms!myformname!myid & ".pdf" 'you can use you own pathing mechanism here I hardcoded a path for you

    Set objOutlook = CreateObject("Outlook.Application")

    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg

    Set objOutlookRecip = .Recipients.Add(strconemail)
    objOutlookRecip.Type = olTo

    Set objOutlookRecip = .Recipients.Add("") 'sends me a copy
    If MsgBox("Are you going to CC another party?", vbYesNo, _
    "CC 3rd Party") = vbYes Then
    Dim strmycc As String
    strmycc = InputBox("Enter One additional CC", "Add CC to List")
    Set objOutlookRecip = .Recipients.Add(strmycc)
    objOutlookRecip.Type = olCC
    End If

    .Subject = mysubject
    mybodyadd = InputBox("Additional notes", "Add More Notes")
    .Body = "There are attachments with this email." & vbCrLf & vbCrLf & _
    mybodyadd & vbCrLf & vbCrLf & "A Pdf file is attached"
    .Importance = olImportanceHigh 'High importance

    If Not IsMissing(mypath) Then
    Set objOutlookAttach = .Attachments.Add(mypath)
    End If

    End With
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
    MsgBox "Your email has been sent to " & strconemail
    If Err.Number = 0 Then
    Exit Sub
    MsgBox Err.Number & vbCrLf & vbCrLf & Err.Description
    Resume Next
    End If

    End Sub

    I use this with pre sr1 release of office 2k so I do not get the outlook patch alerts that says i have a program that is sending an email

    the cdo code I gave you bypasses that altogether regardless of versions and service releases.

    Let me know how it works
    Last edited by axsprog; 06-25-03 at 16:15.

Posting Permissions

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