MAPI control
hi all
i have this code which i shall list below which works great with outlook 2000 and vb6 but with 2003 outlook it just dont work
who = "" & Text3 & "@hotmail.com"
MAPISession1.SignOn
MAPIMessages1.SessionID = MAPISession1.SessionID
If Err <> 0 Then
MsgBox "Logon Failure: " + Error$
End If
MAPIMessages1.SessionID = MAPISession1.SessionID
MAPIMessages1.MsgIndex = -1
MAPIMessages1.Compose
MAPIMessages1.RecipAddress = "" & who
MAPIMessages1.MsgSubject = "Please Review Your Time Sheet"
MAPIMessages1.MsgNoteText = "Sorry, your total job hours exceeded your total week hours, please could you review.."
MAPIMessages1.MsgNoteText = "Thanks"
MAPIMessages1.MsgNoteText = "" & a2 & ""
MAPIMessages1.AttachmentPathName = "" & Text4 & ""
MAPIMessages1.Send True
is there another way to do this or does the code need to be changed for 2003
any help is always appreciated
thanks in advance
Rob
[1004 byte] By [
Spumbu1977] at [2007-11-11 8:08:24]

# 5 Re: MAPI control
i have found a new solution and thought i would post it here for future problems that others may have
just include a reference for outlook 11 / 9 depending on what you are using
Public Sub sndemail()
Dim objOutlook As Outlook.Application
Dim objSession As Outlook.NameSpace
Dim objMessage As Outlook.MailItem 'Object
Dim objRecipient As Object
Dim attachthis As String
Dim adresse As String
attachthis = "" & Text17 & "" 'replace with the textbox that holds the path to the attachment
adresse = "mrwho@yahoo.com"
Set objOutlook = CreateObject("Outlook.Application")
Set objSession = objOutlook.GetNamespace("MAPI")
Set objMessage = objOutlook.CreateItem(olMailItem)
Set objRecipient = objSession.CreateRecipient(adresse)
objSession.Logon
objMessage.Recipients.Add (objRecipient)
objMessage.Subject = "Please enter subject here"
objMessage.Body = "hello just sending you some information"
objMessage.Attachments.Add (attachthis)
objMessage.Send
MsgBox "Message sent successfully!"
Set objRecipient = Nothing
objSession.Logoff
End Sub
to use this this just add a cammand button and place the following code within it
Private sub command1_click()
Call sndemail
End sub
hope this helps you as much as it did me
thanks all
Rob