send email with Exchange and Outlook 2000

  • Thread starter Thread starter Newbie
  • Start date Start date
N

Newbie

I am using Access XP

How can I send an email from code - I had some code that worked in Acc2000
but it doesn't work in XP - it comes up with variable not defined when
trying to specify the type of recipient

..RecipType = mapToList

What am I doing wrong? How can I accomplish this using XP


FYI here is the code:

Dim mapisession As Object
Dim mapimessage As Object
Dim mapirecipient As Object
Dim mapiattachment As Object
Dim Recpt
Dim errObj As Long
Dim errMsg

On Error GoTo mapitrap
Set mapisession = CreateObject("Mapi.Session")
mapisession.Logon profilename:="MS Exchange Settings"
Set mapimessage = mapisession.Outbox.Messages.Add
With mapimessage
Set mapirecipient = mapimessage.Recipients.Add
mapirecipient.Name = "Helpdesk"
.RecipType = mapToList
For Recpt = 1 To .Recipients.Count
..Recipients(Recpt).Resolve showdialog:=False
Next
..MsgSubject = "MIS Error: "
..MsgNoteText = "This following error has occured: .Importance = mapiHigh
..Send False
End With
Set mapisession = Nothing
 
Hi,

mapToList is being seen as a variable name and not a
constant value as expected. This is probably because you
are not referencing the MAPI object library
(Tools>References in VBA). If this is not possible you
need to replace 'mapToList' with the numeric value that it
refers to (can't find it in my documentations offhand).
You will also have to change any other constants to their
value as well.

hth

chas
-----Original Message-----
I am using Access XP

How can I send an email from code - I had some code that worked in Acc2000
but it doesn't work in XP - it comes up with variable not defined when
trying to specify the type of recipient

..RecipType = mapToList

What am I doing wrong? How can I accomplish this using XP


FYI here is the code:

Dim mapisession As Object
Dim mapimessage As Object
Dim mapirecipient As Object
Dim mapiattachment As Object
Dim Recpt
Dim errObj As Long
Dim errMsg

On Error GoTo mapitrap
Set mapisession = CreateObject("Mapi.Session")
mapisession.Logon profilename:="MS Exchange Settings"
Set mapimessage = mapisession.Outbox.Messages.Add
With mapimessage
Set mapirecipient = mapimessage.Recipients.Add
mapirecipient.Name = "Helpdesk"
.RecipType = mapToList
For Recpt = 1 To .Recipients.Count
..Recipients(Recpt).Resolve showdialog:=False
Next
..MsgSubject = "MIS Error: "
..MsgNoteText = "This following error has
occured: .Importance = mapiHigh
 
Thanks for that but I have all the refereneces I had checked in Acc 2000.
Where can I find the numeric values?
Ali
 
Back
Top