Repost: Attachments to Outlook Express possible?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Arno R

    Repost: Attachments to Outlook Express possible?

    Hi all,

    This is a repost of a message posted at october 6.
    The answer I got was about MapiMessages.At tachmentIndex.
    I think I need the MSMAPI32.OCX to use this. (I don't have this file on my PC)

    My newsaccount wasn't working anymore until yesterday, so I'll try again.

    Question is:
    I know it is possible to send email with Access, but can one also automate the attachments?
    Question has been asked a lot I know...
    I've searched Google but *all* answers that work use Outlook or commercial apps?
    So I have not been able yet to automate the attachment-issue using Outlook Express.
    Any ideas or 'new' insight?
    (Using Access '97 or Access 2000)

    TIA
    Arno R





  • Pieter Linden

    #2
    Re: Repost: Attachments to Outlook Express possible?

    Arno,
    did you look on Tony Toews'site in the e-mail section? I'm almost
    positive it's all covered there.


    Comment

    • Lyle Fairfield

      #3
      Re: Repost: Attachments to Outlook Express possible?

      "Arno R" <arracomn_o_s_p _a_m@tiscali.nl > wrote in
      news:3f9530cc$0 $137$5fc3050@dr eader2.news.tis cali.nl:
      [color=blue]
      > Hi all,
      >
      > This is a repost of a message posted at october 6.
      > The answer I got was about MapiMessages.At tachmentIndex.
      > I think I need the MSMAPI32.OCX to use this. (I don't have this file on
      > my PC)
      >
      > My newsaccount wasn't working anymore until yesterday, so I'll try
      > again.
      >
      > Question is:
      > I know it is possible to send email with Access, but can one also
      > automate the attachments? Question has been asked a lot I know...
      > I've searched Google but *all* answers that work use Outlook or
      > commercial apps? So I have not been able yet to automate the
      > attachment-issue using Outlook Express. Any ideas or 'new' insight?
      > (Using Access '97 or Access 2000)
      >
      > TIA
      > Arno R[/color]

      This class should send attachments via Outlook Express. But WHY? CDO is
      much simpler and much stronger.

      Option Explicit

      Private Type MAPIRecip
      Reserved As Long
      RecipClass As Long
      Name As String
      Address As String
      EIDSize As Long
      EntryID As String
      End Type

      Private Type MAPIFileTag
      Reserved As Long
      TagLength As Long
      Tag() As Byte
      EncodingLength As Long
      Encoding() As Byte
      End Type

      Private Type MAPIFile
      Reserved As Long
      Flags As Long
      Position As Long
      PathName As String
      FileName As String
      FileType As Long
      End Type

      Private Type MAPIMessage
      Reserved As Long
      Subject As String
      NoteText As String
      MessageType As String
      DateReceived As String
      ConversationID As String
      Originator As Long
      Flags As Long
      RecipCount As Long
      Recipients As Long
      FileCount As Long
      Files As Long
      End Type

      Private Declare Function MAPISendMail _
      Lib "c:\program files\outlook express\msoe.dl l" ( _
      ByVal Session As Long, _
      ByVal UIParam As Long, _
      ByRef message As MAPIMessage, _
      ByVal Flags As Long, _
      ByVal Reserved As Long) As Long

      Private Const MAPI_E_NO_LIBRA RY = 999
      Private Const MAPI_E_INVALID_ PARAMETER = 998

      Private Const MAPI_ORIG = 0
      Private Const MAPI_TO = 1
      Private Const MAPI_CC = 2
      Private Const MAPI_BCC = 3

      Private Const MAPI_UNREAD = 1
      Private Const MAPI_RECEIPT_RE QUESTED = 2
      Private Const MAPI_SENT = 4

      Private Const MAPI_LOGON_UI = &H1
      Private Const MAPI_NEW_SESSIO N = &H2
      Private Const MAPI_DIALOG = &H8
      Private Const MAPI_UNREAD_ONL Y = &H20
      Private Const MAPI_ENVELOPE_O NLY = &H40
      Private Const MAPI_PEEK = &H80
      Private Const MAPI_GUARANTEE_ FIFO = &H100
      Private Const MAPI_BODY_AS_FI LE = &H200
      Private Const MAPI_AB_NOMODIF Y = &H400
      Private Const MAPI_SUPPRESS_A TTAch = &H800
      Private Const MAPI_FORCE_DOWN LOAD = &H1000

      Private Const MAPI_OLE = &H1
      Private Const MAPI_OLE_STATIC = &H2


      Dim mAf() As MAPIFile
      Dim mAr() As MAPIRecip
      Dim lAr As Long
      Dim lAf As Long
      Dim mM As MAPIMessage
      Dim aErrors(0 To 26) As String

      Private Sub Class_Initializ e()
      aErrors(0) = "Success"
      aErrors(1) = "User Abort"
      aErrors(2) = "Failure"
      aErrors(3) = "LogIn Failure"
      aErrors(4) = "Disk Full"
      aErrors(5) = "Insufficie nt Memory"
      aErrors(6) = "Block Too Small"
      aErrors(8) = "Too Many Sessions"
      aErrors(9) = "Too Many Files"
      aErrors(10) = "Too Many Recipients"
      aErrors(11) = "Attachment No Found"
      aErrors(12) = "Attachment Open Failure"
      aErrors(13) = "Attachment Write Failure"
      aErrors(14) = "Unknown Recipient"
      aErrors(15) = "Bad Recipient"
      aErrors(16) = "No Messages"
      aErrors(17) = "Invalid Message"
      aErrors(18) = "Text Too Large"
      aErrors(19) = "Invalid Session"
      aErrors(20) = "Type Not Suppported"
      aErrors(21) = "Ambiguous Recipient"
      aErrors(22) = "Message in Use"
      aErrors(23) = "Network Failure"
      aErrors(24) = "Invalid Edit Fields"
      aErrors(25) = "Invalid Recipient"
      aErrors(26) = "Not Supported"
      End Sub

      Public Sub BCCAddressAdd(B yVal strAddress As String)
      RecipientAdd MAPI_BCC, , strAddress
      End Sub

      Public Sub BCCNameAdd(ByVa l strName As String)
      RecipientAdd MAPI_BCC, strName
      End Sub

      Public Sub CCAddressAdd(By Val strAddress As String)
      RecipientAdd MAPI_CC, , strAddress
      End Sub

      Public Sub CCNameAdd(ByVal strName As String)
      RecipientAdd MAPI_CC, strName
      End Sub

      Public Sub MessageIs(ByVal strNoteText As String)
      mM.NoteText = strNoteText
      End Sub

      Public Sub SubjectIs(ByVal strSubject As String)
      mM.Subject = strSubject
      End Sub

      Public Sub ToAddressAdd(By Val strAddress As String)
      RecipientAdd MAPI_TO, , strAddress
      End Sub

      Public Sub ToNameAdd(ByVal strName As String)
      RecipientAdd MAPI_TO, strName
      End Sub

      Public Sub FileAdd(ByVal strPathName As String)
      Dim f As MAPIFile
      With f
      .PathName = StrConv(strPath Name, vbFromUnicode)
      End With
      ReDim Preserve mAf(lAf)
      mAf(lAf) = f
      lAf = lAf + 1
      End Sub

      Public Sub Send()
      Dim r As Long
      With mM
      If lAf > 0 Then
      .FileCount = lAf
      .Files = VarPtr(mAf(0))
      End If
      If lAr > 0 Then
      .RecipCount = lAr
      .Recipients = VarPtr(mAr(0))
      r = MAPISendMail(0, 0, mM, 0, 0)
      If r <> 0 Then MsgBox aErrors(r)
      End If
      End With
      End Sub

      Private Sub RecipientAdd(By Val lngType As Long, _
      Optional ByVal strName As String, Optional ByVal strAddress As String)
      Dim r As MAPIRecip
      r.RecipClass = lngType
      If strName <> "" Then r.Name = StrConv(strName , vbFromUnicode)
      If strAddress <> "" Then r.Address = StrConv(strAddr ess,
      vbFromUnicode) ReDim Preserve mAr(lAr)
      mAr(lAr) = r
      lAr = lAr + 1
      End Sub


      --
      Lyle
      (for e-mail refer to http://ffdba.com/contacts.htm)

      Comment

      • Arno R

        #4
        Re: Repost: Attachments to Outlook Express possible?

        Hi Pieter, thanks for replying.

        (Again my newsserver is not working @#$%@##$$
        so I created a Google-account to reply)

        I did search and looked (more than once) on Tony's site. Good stuff
        and good info but not exactly on the topic I need.
        Maybe I misread or overlooked, but I only found examples including
        attachments that used Outlook (not Outlook Express)or it was third
        party vendor stuff.
        What I am looking for is a way to automate emails with and without
        attachments that will *always* work with my clients.
        I prefer not to use ocx-controls or dll's that might not be present at
        my client's computers.

        Arno R

        pietlinden@hotm ail.com (Pieter Linden) wrote in message news:<bf31e41b. 0310211116.7922 952e@posting.go ogle.com>...[color=blue]
        > Arno,
        > did you look on Tony Toews'site in the e-mail section? I'm almost
        > positive it's all covered there.
        >
        > http://www.granite.ab.ca/access/email.htm[/color]

        Comment

        • Arno R

          #5
          Re: Repost: Attachments to Outlook Express possible?

          Hi Lyle,
          [color=blue]
          > This class should send attachments via Outlook Express. But WHY? CDO is
          > much simpler and much stronger.[/color]
          I need info for OE because not all of my clients will have the
          CDO-library installed.
          Or am I missing something obvious here?

          Thanks very much for the info but, could you explain a bit more on how
          to use this code please?
          I guess I start with initializing the class but this immediately
          errors?

          TIA
          Arno R

          Comment

          • Lyle Fairfield

            #6
            Re: Repost: Attachments to Outlook Express possible?

            arracom@tiscali .nl (Arno R) wrote in news:7599ce12.0 310230414.34a5a 665
            @posting.google .com:
            [color=blue]
            > Hi Lyle,
            >[color=green]
            >> This class should send attachments via Outlook Express. But WHY? CDO is
            >> much simpler and much stronger.[/color]
            > I need info for OE because not all of my clients will have the
            > CDO-library installed.
            > Or am I missing something obvious here?
            >
            > Thanks very much for the info but, could you explain a bit more on how
            > to use this code please?
            > I guess I start with initializing the class but this immediately
            > errors?[/color]

            Should I guess what these errors are?

            --
            Lyle
            (for e-mail refer to http://ffdba.com/contacts.htm)

            Comment

            • Arno R

              #7
              Re: Repost: Attachments to Outlook Express possible?

              Hi Pieter, thanks for replying.

              I did search and looked (more than once) on Tony's site. Good stuff and good info but not exactly on
              the topic I need.
              Maybe I misread or overlooked, but I only found examples including attachments that used Outlook
              (not Outlook Express)
              or it was third party vendor stuff.
              What I am looking for is a way to automate emails with and without attachments that will *always*
              work with my clients.
              I prefer not to use ocx-controls or dll's that might not be present at my client's computers.

              "Pieter Linden" <pietlinden@hot mail.com> schreef in bericht
              news:bf31e41b.0 310211116.79229 52e@posting.goo gle.com...[color=blue]
              > Arno,
              > did you look on Tony Toews'site in the e-mail section? I'm almost
              > positive it's all covered there.
              >
              > http://www.granite.ab.ca/access/email.htm[/color]





              Comment

              • Arno R

                #8
                Re: Repost: Attachments to Outlook Express possible?

                Lyle, I am not waiting for such a 'guess'.
                What I need is an answer that I understand.

                If I ask stupid questions allright, let me know, but I still would appreciate if you help me out on
                this.

                Arno R


                "Lyle Fairfield" <MissingAddress @Invalid.Com> schreef in bericht
                news:Xns941DB64 C81AA8FFDBA@130 .133.1.4...[color=blue]
                > arracom@tiscali .nl (Arno R) wrote in news:7599ce12.0 310230414.34a5a 665
                > @posting.google .com:
                >[color=green]
                > > Hi Lyle,
                > >[color=darkred]
                > >> This class should send attachments via Outlook Express. But WHY? CDO is
                > >> much simpler and much stronger.[/color]
                > > I need info for OE because not all of my clients will have the
                > > CDO-library installed.
                > > Or am I missing something obvious here?
                > >
                > > Thanks very much for the info but, could you explain a bit more on how
                > > to use this code please?
                > > I guess I start with initializing the class but this immediately
                > > errors?[/color]
                >
                > Should I guess what these errors are?
                >
                > --
                > Lyle
                > (for e-mail refer to http://ffdba.com/contacts.htm)[/color]


                Comment

                • Peter Doering

                  #9
                  Re: Repost: Attachments to Outlook Express possible?

                  [color=blue][color=green][color=darkred]
                  >>> I guess I start with initializing the class but this immediately
                  >>> errors?[/color][/color][/color]
                  [color=blue][color=green]
                  >> Should I guess what these errors are?
                  >>[/color][/color]

                  Lyle would like to know what error you are referring to. I believe it's
                  because of some line wraps at wrong positions:
                  [color=blue]
                  > Private Sub RecipientAdd(By Val lngType As Long, _ ...
                  > ...
                  > If strAddress <> "" Then r.Address = StrConv(strAddr ess,
                  > vbFromUnicode) ReDim Preserve mAr(lAr)[/color]

                  should read:

                  If strAddress <> "" Then r.Address = _
                  StrConv(strAddr ess, vbFromUnicode)
                  ReDim Preserve mAr(lAr)


                  HTH - Peter

                  --
                  No mails please.

                  Comment

                  • Larry  Linson

                    #10
                    Re: Repost: Attachments to Outlook Express possible?

                    "Arno R" wrote
                    [color=blue]
                    > Lyle, I am not waiting for such a 'guess'.
                    > What I need is an answer that I understand.
                    >
                    > If I ask stupid questions allright, let me
                    > know, but I still would appreciate if you
                    > help me out on this.[/color]

                    Lyle and I have disagreed on many issues, but I agree with him on this one.
                    If you want help, you have to describe the problem in detail and with care.
                    Precise and concise questions are the ones most likely to be answered. Don't
                    whine when someone helping you asks for information, even if you think that
                    person is being "snippy".

                    A perfectly understandable response to a whine in reply to a request for
                    information needed to help someone is no response at all. However, it would
                    likely be worth your while to provide the specific information he asked
                    about. He might then be able to help, or someone else might.

                    Larry Linson


                    Comment

                    • Arno R

                      #11
                      Re: Repost: Attachments to Outlook Express possible?

                      Hi Chuck,
                      Thanks for your reply,
                      [color=blue]
                      > BTW, what are your plans for places that have OE removed, or places
                      > that use Groupwise? (OE and Groupwise don't get along all that well!)[/color]

                      To be more specific: All my clients (for this specific app) have 'at least' OE installed.
                      Some have Outlook or other mail-clients (Eudora is one of them).
                      I guess they all are MAPI-compliant or not?
                      So what I really need is a generic MAPI-solution without ocx-controls or dll's
                      that might not be present at my client's computers.


                      Arno R


                      Comment

                      • Arno R

                        #12
                        Re: Repost: Attachments to Outlook Express possible?

                        Hi Lyle,
                        I guess I owe you an apology. I totally misread your reply!
                        I am really sorry for that!
                        Peter and Larry both are teling me that you are right, and you are!
                        I totally misunderstood your 'guessing'. (I guess I was a bit pissed because my newsserver failed
                        again)
                        Again: I am sorry and appreciate your help.

                        It's not the line-wrap that errors (thanks Peter) but it's probably the fact that I don't fully
                        understand the code.
                        So I ask for more explanation. (Hope I am specific enough now)

                        What did I try?
                        I pasted the code in a new module. (fixed the line-wrap)
                        I get an error on the first line with code in a form like:

                        Sub TestMail()
                        Class_Initializ e
                        ToAddressAdd "address@test.n l"
                        BCCAddressAdd "info@test. nl"
                        MessageIs "bla bla" & vbNewLine & "second line here"
                        SubjectIs "Testmail"
                        FileAdd "C:\test\test.z ip"
                        Send
                        end sub

                        If I comment-out the first line indeed a mailmessage (with attachment!) shows up in the OE-Outbox,
                        great!!
                        But how or when is the Class_Initializ e code used?

                        Other problems:
                        When I use the sub again the ToAddress-line and BCCAddress-line are doubled.
                        ToAddress: address@test.nl ;address@test.n l
                        BCCAddress: info@test.nl;in fo@test.nl
                        Also the attachment shows up twice
                        (or trippled on the third try and so on)
                        What am I doing wrong ?

                        Arno R


                        "Lyle Fairfield" <MissingAddress @Invalid.Com> schreef in bericht
                        news:Xns941DB64 C81AA8FFDBA@130 .133.1.4...[color=blue]
                        > arracom@tiscali .nl (Arno R) wrote in news:7599ce12.0 310230414.34a5a 665
                        > @posting.google .com:
                        >[color=green]
                        > > Hi Lyle,
                        > >[color=darkred]
                        > >> This class should send attachments via Outlook Express. But WHY? CDO is
                        > >> much simpler and much stronger.[/color]
                        > > I need info for OE because not all of my clients will have the
                        > > CDO-library installed.
                        > > Or am I missing something obvious here?
                        > >
                        > > Thanks very much for the info but, could you explain a bit more on how
                        > > to use this code please?
                        > > I guess I start with initializing the class but this immediately
                        > > errors?[/color]
                        >
                        > Should I guess what these errors are?
                        >
                        > --
                        > Lyle
                        > (for e-mail refer to http://ffdba.com/contacts.htm)[/color]


                        Comment

                        • Arno R

                          #13
                          Re: Repost: Attachments to Outlook Express possible?

                          Hi Lyle,

                          I just found out what I did wrong and I'm a little embarassed about it...
                          Its class-code, so I need to paste the code in a class-module and use the class!
                          Obviously I am not used to class-code ;-)
                          Anyhow, finally I got it working. I think I need to study more about classes now!

                          Thanks,
                          Arno R



                          Comment

                          Working...