Solved

Send attachment without MAPI controls

Posted on 1998-05-10
4
220 Views
Last Modified: 2012-06-21
I am doing this in Access 97.  I am attempting to send and receive MAPI messages with attached files and cannot get SIMPLE MAPI go do it.  I believe SIMPLE MAPI cannot.  I have tried with the msmapi32.ocx control but cannot get this to distribute to the client PC so I have given up.

Is there any other method of using attachments in MAPI without the msmapi32.ocx control.  Also, my cilents are using Exchange and not Outlook so I don't think Outlook Automation will work.

Thanks,
Ken

Bonus Question: How can I find out the default MAPI profile for a use so that I don't need to ask them the first time they use the application?  It must be possible since forcing the profile dialog to appear has the default profile as the default selection in the dialog's combo box.

Thanks
0
Comment
Question by:kfenske
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:zsi
ID: 1445444
kfenske,

Regarding the OCX issue.  I noticed that you made another post about difficulties that you are experiencing in distributing your application.  Once you have resolved that problem, you will find that the msmapi32.ocx problem should go away.

There are alternatives to using msmapi.  In addition to third-party controls (such as Quiksoft's EasyMail, et. al.), you can program directly to the MAPI API layer.  However, I don't recommend it.  It takes a lot of work, is not well documented, and I am not even sure if you can do it directly from Access.  The OCX is there for a reason :)


You can determine the default MAPI profile by reading the registry.  
In NT, this information is found at HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\DefaultProfile"

In 95, it's at HKEY_CURRENT_USER\Software\Microsoft\Windows Messaging Subsystem\Profiles\DefaultProfile"

Hope this helps!

zsi
0
 

Author Comment

by:kfenske
ID: 1445445
I have two questions concerning your helpful answer:
1. Do you know if there might be a licensing issue I'm running into?  I once got a message to that effect during testing but can't find any info on a file or registry entry to add for the license.

2. Thanks for the profile info, could you tell me how to read the registry from Access Basic?

Thanks,
Ken
0
 
LVL 4

Accepted Solution

by:
zsi earned 100 total points
ID: 1445446
I'm not sure what might be causing the license problem.  It only came up once, you say?

As for the registry, Access 97 Basic is actually a subset of Visual Basic.  Therefore, the following code should work.  You might have to play with it a little to get it to work in Access...

Put the following code in its own code module:
------------------------------------------------------------------
Option Explicit


Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueExStr Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long
Private Declare Function RegSetValueExStr Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Private Declare Function RegFlushKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_SZ = 1
Private Const ERROR_SUCCESS = 0&
Function GetRegValue(lRoot As Long, sKey As String, sEntry As String) As String
   
   Dim Ret As Long
   Dim hKey As Long
   Dim KeyName As String
   Dim Ret2 As Long
   Dim I As Integer
   Dim sValue As String
   Dim l As Long
   
   
   sValue = Space(256)
   Ret = RegOpenKey(lRoot, sKey, hKey)
   
   If Ret = ERROR_SUCCESS Then
      l = 256
     
      Ret2 = RegQueryValueExStr(hKey, sEntry, 0&, REG_SZ, sValue, l)
     
      If Ret2 = ERROR_SUCCESS Then
         If l > 0 Then  ' if it's more than just a null
            GetRegValue = Left(sValue, l - 1)
         End If
      End If
     
      Ret = RegCloseKey(hKey)
   
   End If
   
End Function


--------------------------
To get the registry value, invoke this command

DefProf = GetRegValue(HKEY_CURRENT_USER, "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles", "DefaultProfile")

This example is for WinNT.  For Win95, just use the line

DefProf = GetRegValue(HKEY_CURRENT_USER, "Software\Microsoft\Windows Messaging Subsystem\Profiles", "DefaultProfile")

0
 

Author Comment

by:kfenske
ID: 1445447
I think I figured out the problem with licensing.  It seems that I had copied the mapisession and mapimessage objects from my VB app to the Access app.  While this worked fine on my machine it did not work on the client.  When I recreated the objects directly in Access it seems to have fixed the problem.

Thanks for the great answer on the registry!

Ken
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now