
**** Send a mailing using MS ACCESS 95 with or without MS EXCHANGE SERVER *****
Quote:
>I have an Access database filled with al my clients. The database also
>includes their e-mail addresses. Now I want to send a mailing using this
>database.
>I have already written the code to send this mailing to every client. I do
>this using the SendObject-action. Every client now gets a personalised
>e-mail without all the other e-mail addresses in the TO-field.
> Here comes the problem: I want the message to contain an attachment.
>I want to send a file (which is not inside my database) with this mailing.
>I also have MS Exchange Server. Maybe there is an option where I can send a
>default message, which contains my attachment.
>If anyone can help me I would be very grateful.
>Marco Langebeeke.
Marco:
As the other commentors have said, SendObject doesn't support attachments.
However, with a little perserverance you can write some pretty simple code
to add attachments to mail using Microsoft's FREE, ActiveMessaging / OLE
Messaging capability for MAPI (Read Exchange, VIM etc.)
Go to this url:
http://www.microsoft.com/syspro/technet/boes/bo/mailexch/exch/tools/a...
actmsg.htm and download Active Messaging 1.1 it contains a help file
which discusses all the objects for interacting with MAPI. Install the
ActiveMessaging dlls.
If you have Excel (preferably Excel 5 or 95,) then you can also go to:
ftp://ftp.microsoft.com/developr/MAPI/samples/OLEMSG and download
olemsg.zip, which contains a ton of VBA code in a couple of Excel modules to
show you how to interact with ActiveMessaging.
Once you get familiar with the MAPI objects, logging on and off etc., here's
a little code snipet which comes from one of our apps showing how to add an
attachment to mail.
'---------------------------------------------------------------------------
----------------------------------------------------------
Public Function SendMail(MailName$, NameResolve As Boolean, MsgSubject$,
MsgText$, AttachmentName$, Attachment$, Optional MailType, Optional
MailAddress) As Boolean
'---------------------------------------------------------------------------
----------------------
'? 1996-97 ATTAC Consulting Group, Ann Arbor, MI USA
'---------------------------------------------------------------------------
----------------------
On Error GoTo Err_SM
Dim ObjMessageColl As Object
Dim ObjMessage As Object
Dim ObjRecipColl As Object
Dim ObjRecipient As Object
Dim ObjAttachmentsColl As Object
Dim ObjAttachment As Object
SendMail = True
If ObjSession Is Nothing Then
'ObjSession is MAPI session object created in a separate LogOn
function
If Mapi_LogOn("", "") = False Then
SendMail = False
GoTo Exit_SM
End If
End If
Set ObjMessageColl = ObjSession.Outbox.Messages
Set ObjMessage = ObjMessageColl.Add
ObjMessage.Subject = MsgSubject
ObjMessage.Text = MsgText
Set ObjRecipColl = ObjMessage.Recipients
Set ObjRecipient = ObjRecipColl.Add
If NameResolve = True Then 'Recipient is in the Address Book
ObjRecipient.Name = MailName
ObjRecipient.Resolve
Else
ObjRecipient.Name = MailName 'Recipient is not in Address book
e.g. SMTP
ObjRecipient.Address = MailType & ":" & MailAddress
End If
If Len(AttachmentName) > 0 Then
Set ObjAttachmentsColl = ObjMessage.Attachments
Set ObjAttachment = ObjAttachmentsColl.Add
ObjAttachment.Name = AttachmentName
ObjAttachment.Type = 1 'File Attachment
ObjAttachment.Position = 0
ObjAttachment.ReadFromFile (Attachment)
End If
ObjMessage.Update
ObjMessage.Send ShowDialog:=False
Exit_SM:
Exit Function
Err_SM:
SendMail = False
Resume Exit_SM
End Function
HTH
-----------
Steve Arbaugh
ATTAC Consulting Group
web: http://ourworld.compuserve.com/homepages/attac-cg/acgsoft.htm
Reply Address adjusted to control spams remove leading ~ and NoSpm from
address