473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Help with Mapi emailing

Hi All,
I've been using this function which I got from here for some time now
in two of my AccessXP multiusers applications and it has worked
without issue until lately it has stopped functioning on several user
pc's and I don't know why. I've asked our PC Services group what they
changed on the pc's that this does not work on and they say 'nothing'.
Well something has changed cause this did work at one time.

When I step thru it in debug mode it errors on the very first line of
code - Set MapiSession = CreateObject("Mapi.Session")
it display an error number 2147221934 which I could not find in
looking thru the Mapi error messages.

Anyone know what might be happening???
thanks
bobh.
Public Function SendMAPIMessage(strSubj As String, strMesTxt As
String, strAttchFile As String, strFrom As String)
On Error GoTo MAPITrap

' This procedure sets an object variable to the MAPI Session Object
' using the CreateObject() function. Then, it logs on to the session
' using a predefined profile. Once logged on, the procedure creates
' a new message and adds it to the Messages collection of the User 's
' OutBox. Then, it creates two recipients (one on the TO: line and
' one on the CC: line) and adds both to the Recipients collection
' of the message. Next, it resolves the names of all recipients.
' Then, it attaches a sample file before filling in the Subject,
' Text, and Importance attributes of the message.
'--------------------------------------------------------------------
Const mapiNormal = 3
Const mapiHigh = 2

Dim MapiSession As Object, MapiMessage As Object
Dim MapiRecipient As Object, MapiAttachment As Object
Dim errObj As Long
Dim errMsg
' Create the MAPI Session.
Set MapiSession = CreateObject("Mapi.Session")

' Log on to the session. If the ProfileName argument is omitted,
' Microsoft Exchange prompts you for the profile to use. If the
' profile name is incorrect, you will receive a runtime error.
MapiSession.Logon profilename:="Novell Default Settings"

' Add a message to the Outbox.
Set MapiMessage = MapiSession.Outbox.Messages.Add

' Add the recipients of the message. Note, each recipient must be
' added separately to the Recipients collection of the Message object.
With MapiMessage
'Set MapiRecipient = MapiMessage.Recipients.Add
'MapiRecipient.Name = "so******@company.com"

'Set MapiRecipient = MapiMessage.Recipients.Add
'MapiRecipient.Name = "so*****@here.com"

'Attach a file to the message.
Set MapiAttachment = MapiMessage.Attachments.Add
With MapiAttachment
.Name = strAttchFile
.Position = 2880
.Type = 1
.ReadFromFile FileName:=strFrom
End With

'Assign the text, subject, and importance of the message.
.Subject = strSubj
.Text = strMesTxt
.Importance = mapiHigh

'View the message in Microsoft Exchange before sending.
'Set the ShowDialog argument to False if you want to send the
'message without viewing it in Microsoft Exchange.
.Send showdialog:=True

End With

Set MapiSession = Nothing ' Clear the object variable.

MAPIExit:
Exit Function

MAPITrap:
errObj = Err - vbObjectError ' Strip out the OLE automation
error.
Select Case errObj
Case 275 ' User cancelled sending of
message.
Resume MAPIExit
Case Else
errMsg = MsgBox("Error " & errObj & " was returned.")
Resume MAPIExit
End Select

End Function

May 10 '07 #1
1 2840
On 10 May 2007 12:47:44 -0700, bobh <vu******@isp.comwrote:

I sometimes get errors on that line if CDO is not installed:
http://support.microsoft.com/default...b;en-us;171440

-Tom.
>Hi All,
I've been using this function which I got from here for some time now
in two of my AccessXP multiusers applications and it has worked
without issue until lately it has stopped functioning on several user
pc's and I don't know why. I've asked our PC Services group what they
changed on the pc's that this does not work on and they say 'nothing'.
Well something has changed cause this did work at one time.

When I step thru it in debug mode it errors on the very first line of
code - Set MapiSession = CreateObject("Mapi.Session")
it display an error number 2147221934 which I could not find in
looking thru the Mapi error messages.

Anyone know what might be happening???
thanks
bobh.
Public Function SendMAPIMessage(strSubj As String, strMesTxt As
String, strAttchFile As String, strFrom As String)
On Error GoTo MAPITrap

' This procedure sets an object variable to the MAPI Session Object
' using the CreateObject() function. Then, it logs on to the session
' using a predefined profile. Once logged on, the procedure creates
' a new message and adds it to the Messages collection of the User 's
' OutBox. Then, it creates two recipients (one on the TO: line and
' one on the CC: line) and adds both to the Recipients collection
' of the message. Next, it resolves the names of all recipients.
' Then, it attaches a sample file before filling in the Subject,
' Text, and Importance attributes of the message.
'--------------------------------------------------------------------
Const mapiNormal = 3
Const mapiHigh = 2

Dim MapiSession As Object, MapiMessage As Object
Dim MapiRecipient As Object, MapiAttachment As Object
Dim errObj As Long
Dim errMsg
' Create the MAPI Session.
Set MapiSession = CreateObject("Mapi.Session")
<clip>

May 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Siegfried Heintze | last post by:
Does the Outlook API supersede MAPI? If I implement a SPAM filter using MAPI to automatically delete messages from the message store, will other clients like Eudora benefit? If I implement a...
4
by: Kurt | last post by:
Hi I am using CDO 1.21 from C# in order to iterate through the entries in a users outlook address book (as OOM was too slow). Basically I take the Name field from each "message" and insert it into...
7
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
4
by: Ottar | last post by:
Error: 80040108 after 380 CreateObject("MAPI.Session") Function MAPI_Test2() Dim i As Integer Dim MySession As MAPI.Session i = 0 While (i < 2000) Set MySession =...
0
by: bobdydd | last post by:
Hi Everybody Can anyone help with this mindbender We are writing an application that uses a VB built DLL to send emails using CDO 1.21. Whether we use the VB DLL or code the CDO stuff...
2
by: Rico | last post by:
Hello, I'm using formmail.asp which is an emailing utility. Basically, the user fills out a request page, clicks "Submit" and the page posts to formmail.asp which emails the user information. ...
8
by: Steve Le Monnier | last post by:
Can anybody help with the following: I have some old VB6 code that loops through my inbox looking for emails with attachments and then save them to the hard drive. The code is very simplistic so I...
3
by: GayathriP | last post by:
This article discusses about how can we access the inbox through MAPI using C# .NET. It also discusses about how to store the attachment in the local directory, how to create a folder in the inbox ...
15
by: squrel | last post by:
Hi everyone.. i need ur help once more time.... i have a form called reminder..in tht form i have: txtid, txtcaseid, txtreminder, cmbremindby(system or user), txtremindto, dtpreminddt,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.