-
March 9th, 2004, 06:56 AM
#1
Outlook Express
Hi Gurus!
I have a small problem. It concerns Outlook Express. For the moment I've an app that starts Microsoft Outlook an attachs a file in the following way.
Dim outlook As Object
Dim objoutlookmsg As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objoutlookmsg = objOutlook.CreateItem(0)
With objoutlookmsg
.To = Emailstr
.Subject = "Hers is the requested File"
.Attachments.Add (FilePath)
.Display
End With
It was said that the Application only should deal with Microsoft Outlook. That would never change.
SURPRISE !!! Yesterday my Boss came down and told me that we have a Customer and is it maybe possible to......
My question is: Is it possible to start Outlook Express in a similar manner as Microsoft Outlook ? And how do I determine which one of Outlook Express and Microsoft Outlook that is the default ?
I've search this forum but haven't found a similar way.
Thanks in advance
-
March 9th, 2004, 07:13 AM
#2
I seem to remember that Outlook Express doesn't expose an object model, not positive tho...?
If not, you'll have to go the MAPI or SMTP way....
-
March 9th, 2004, 08:01 AM
#3
Thanks anyway Dmorley !
Do you know an easy way to determine the default eamil-system ?
Microsoft Outlook or Outlook Express ?
LasseSmall
-
April 12th, 2004, 09:18 AM
#4
I had the same problem
here one solution reading taking the default client from the registry. just copy and paste the code below in a module. "Client" returns the default mail client as string. enjoy!
Regards
RudiFD
[Option Explicit
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Const HKEY_CURRENT_USER = &H80000001
Public Const HKEY_LOCAL_MACHINE = &H80000002
Public Const HKEY_USERS = &H80000003
Public Const HKEY_CURRENT_CONFIG = &H80000005
Public Const HKEY_DYN_DATA = &H80000006
Public Const REG_SZ = 1 'Unicode nul terminated string
Public Const REG_BINARY = 3 'Free form binary
Public Const REG_DWORD = 4 '32-bit number
Public Const ERROR_SUCCESS = 0&
Public Declare Function RegCloseKey Lib "advapi32.dll" _
(ByVal hKey As Long) As Long
Public Declare Function RegCreateKey Lib "advapi32.dll" _
Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey _
As String, phkResult As Long) As Long
Public Declare Function RegDeleteKey Lib "advapi32.dll" _
Alias "RegDeleteKeyA" (ByVal hKey As Long, ByVal lpSubKey _
As String) As Long
Public Declare Function RegDeleteValue Lib "advapi32.dll" _
Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal _
lpValueName As String) As Long
Public Declare Function RegOpenKey Lib "advapi32.dll" _
Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey _
As String, phkResult As Long) As Long
Public Declare Function RegQueryValueEx Lib "advapi32.dll" _
Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName _
As String, ByVal lpReserved As Long, lpType As Long, lpData _
As Any, lpcbData As Long) As Long
Public Declare Function RegSetValueEx Lib "advapi32.dll" _
Alias "RegSetValueExA" (ByVal hKey As Long, ByVal _
lpValueName As String, ByVal Reserved As Long, ByVal _
dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Client As String
Public Function GetSettingString(hKey As Long, _
strPath As String, strValue As String, Optional _
Default As String) As String
Dim hCurKey As Long
Dim lResult As Long
Dim lValueType As Long
Dim strBuffer As String
Dim lDataBufferSize As Long
Dim intZeroPos As Integer
Dim lRegResult As Long
'Set up default value
If Not IsEmpty(Default) Then
GetSettingString = Default
Else
GetSettingString = ""
End If
lRegResult = RegOpenKey(hKey, strPath, hCurKey)
lRegResult = RegQueryValueEx(hCurKey, strValue, 0&, _
lValueType, ByVal 0&, lDataBufferSize)
If lRegResult = ERROR_SUCCESS Then
If lValueType = REG_SZ Then
strBuffer = String(lDataBufferSize, " ")
lResult = RegQueryValueEx(hCurKey, strValue, 0&, 0&, _
ByVal strBuffer, lDataBufferSize)
intZeroPos = InStr(strBuffer, Chr$(0))
If intZeroPos > 0 Then
GetSettingString = Left$(strBuffer, intZeroPos - 1)
Else
GetSettingString = strBuffer
End If
End If
Else
'there is a problem
End If
lRegResult = RegCloseKey(hCurKey)
End Function
Public Function Get_Mail_Client() As String
Client = GetSettingString(HKEY_LOCAL_MACHINE, "Software\Clients\Mail", " ")
End Function
]
-
April 12th, 2004, 10:05 AM
#5
here some more to regarding to your prob
to start and fill out an email using Outlook Express use the code below.
Note: you must install 1 command button and MAPI32 Controls 6.0. The attached file must exist in a valid directory here the code:
[Option Explicit
Private bNewSession As Boolean ' Flag to signal logon status.
Dim Recipent As String
Dim Subject As String
Dim NoteText As String
Dim Attachment As String
Private Sub ComposeMessage(Recipent As String, Optional Subject As String, _
Optional NoteText As String, Optional Attachment As String)
With MAPIMessages1
.Compose
.RecipAddress = Recipent
.MsgSubject = Subject
.MsgNoteText = NoteText
.AttachmentPathName = Attachment
.Send True 'if you would like to send the mail straight away
End With
End Sub
Private Function LogOn() As Boolean
If MAPISession1.NewSession Then
MsgBox "Session already established"
Exit Function
End If
On Error GoTo errLogInFail
With MAPISession1
.DownLoadMail = False ' Set DownLoadMail to False to prevent immediate download.
'.LogonUI = True ' Use the underlying email system's logon UI.
.SignOn ' Signon method.
.NewSession = True
bNewSession = .NewSession
MAPIMessages1.SessionID = .SessionID ' You must set this before continuing.
End With
Exit Function
errLogInFail:
Debug.Print Err.Number, Err.Description
If Err.Number = 32003 Then
MsgBox "Canceled Login"
LogOn = False
End If
Exit Function
End Function
Private Sub LogOff()
If MAPISession1.SessionID <> 0 Then MAPISession1.SignOff
With MAPISession1
.NewSession = False ' Flag for new session.
bNewSession = .NewSession ' Reset flag.
End With
End Sub
Private Sub Command1_Click()
LogOn
ComposeMessage "someone@somewhere.com", "Test", "Some notes", "C:\autoexec.bat"
End Sub]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|