By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,660 Members | 1,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,660 IT Pros & Developers. It's quick & easy.

Repost: Attachments to Outlook Express possible?

P: n/a
Hi all,

This is a repost of a message posted at october 6.
The answer I got was about MapiMessages.AttachmentIndex.
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

Nov 12 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
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
Nov 12 '05 #2

P: n/a
"Arno R" <ar****************@tiscali.nl> wrote in
news:3f********************@dreader2.news.tiscali. nl:
Hi all,

This is a repost of a message posted at october 6.
The answer I got was about MapiMessages.AttachmentIndex.
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


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.dll" ( _
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_LIBRARY = 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_REQUESTED = 2
Private Const MAPI_SENT = 4

Private Const MAPI_LOGON_UI = &H1
Private Const MAPI_NEW_SESSION = &H2
Private Const MAPI_DIALOG = &H8
Private Const MAPI_UNREAD_ONLY = &H20
Private Const MAPI_ENVELOPE_ONLY = &H40
Private Const MAPI_PEEK = &H80
Private Const MAPI_GUARANTEE_FIFO = &H100
Private Const MAPI_BODY_AS_FILE = &H200
Private Const MAPI_AB_NOMODIFY = &H400
Private Const MAPI_SUPPRESS_ATTAch = &H800
Private Const MAPI_FORCE_DOWNLOAD = &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_Initialize()
aErrors(0) = "Success"
aErrors(1) = "User Abort"
aErrors(2) = "Failure"
aErrors(3) = "LogIn Failure"
aErrors(4) = "Disk Full"
aErrors(5) = "Insufficient 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(ByVal strAddress As String)
RecipientAdd MAPI_BCC, , strAddress
End Sub

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

Public Sub CCAddressAdd(ByVal 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(ByVal 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(strPathName, 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(ByVal 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(strAddress,
vbFromUnicode) ReDim Preserve mAr(lAr)
mAr(lAr) = r
lAr = lAr + 1
End Sub
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #3

P: n/a
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

pi********@hotmail.com (Pieter Linden) wrote in message news:<bf**************************@posting.google. com>...
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

Nov 12 '05 #4

P: n/a
Hi Lyle,
This class should send attachments via Outlook Express. But WHY? CDO is
much simpler and much stronger.

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
Nov 12 '05 #5

P: n/a
ar*****@tiscali.nl (Arno R) wrote in news:7599ce12.0310230414.34a5a665
@posting.google.com:
Hi Lyle,
This class should send attachments via Outlook Express. But WHY? CDO is
much simpler and much stronger.

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?


Should I guess what these errors are?

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #6

P: n/a
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" <pi********@hotmail.com> schreef in bericht
news:bf**************************@posting.google.c om...
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


Nov 12 '05 #7

P: n/a
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" <Mi************@Invalid.Com> schreef in bericht
news:Xn*******************@130.133.1.4...
ar*****@tiscali.nl (Arno R) wrote in news:7599ce12.0310230414.34a5a665
@posting.google.com:
Hi Lyle,
This class should send attachments via Outlook Express. But WHY? CDO is
much simpler and much stronger.

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?


Should I guess what these errors are?

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

Nov 12 '05 #8

P: n/a
I guess I start with initializing the class but this immediately
errors?
Should I guess what these errors are?

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


should read:

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

--
No mails please.
Nov 12 '05 #9

P: n/a
"Arno R" wrote
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.


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
Nov 12 '05 #10

P: n/a
Hi Chuck,
Thanks for your reply,
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!)


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
Nov 12 '05 #11

P: n/a
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_Initialize
ToAddressAdd "ad*****@test.nl"
BCCAddressAdd "in**@test.nl"
MessageIs "bla bla" & vbNewLine & "second line here"
SubjectIs "Testmail"
FileAdd "C:\test\test.zip"
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_Initialize code used?

Other problems:
When I use the sub again the ToAddress-line and BCCAddress-line are doubled.
ToAddress: ad*****@test.nl;ad*****@test.nl
BCCAddress: in**@test.nl;in**@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" <Mi************@Invalid.Com> schreef in bericht
news:Xn*******************@130.133.1.4...
ar*****@tiscali.nl (Arno R) wrote in news:7599ce12.0310230414.34a5a665
@posting.google.com:
Hi Lyle,
This class should send attachments via Outlook Express. But WHY? CDO is
much simpler and much stronger.

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?


Should I guess what these errors are?

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

Nov 12 '05 #12

P: n/a
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

Nov 12 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.