Tlogix
asked on
VB6 MAPI MS OUTLOOK 2002 SEND EMAIL TYPE PROBLEM
I'm trying to use MAPI to send a mail with MS Outlook as the default email client.
Local machine running XPpro and using smtp email account as default. My application utlizes a custom form MS Outlook Form.
The following code works with no problem for Outlook 2000, meaning that it opens a new MailItem Form with the info, and after clicking send it puts the message in outbox…and it can be sent (Outlook 2000 in Internet Mode).
Now the problems appear in Outlook 2002 and 2003. It also creates the MailItem Form with the info, when I send the meassge, it moves from the outbox to the inbox as undelverable mail. When I look at email properties in the message form the E-mail Type field is the same the email address - with internet type defaulted. When I click on internet type button the E-mail Type field changes to SMTP, with this change, I can send the email, and it goes out with any problems. Like wise when I try to email in the standard manner, open contact dclick on the email address (btw: here it's defaulted to smtp) create and send an email.
So how do I set E-mail Type from MAPI, what am I missing here … if someone encountered this and has a workaround or knows what’s causing this (maybe how to set the transport protocol settings) or whatever - appreciate your taking time in responding to this.
Not sure at this point if it's local settings, Custom form settings or MAPI code, the idea here is that code should adopt the clients default email settings and email should go out without any manual changes or errors.
Thanks.
_________________________C ode Sample:___________________ __________ __________ _____
Private Type MAPIMessage
Reserved As Long
Subject As String
NoteText As String
MessageType As String
DateReceived As String
ConversationID As String
Flags As Long
RecipCount As Long
FileCount As Long
End Type
Private Type MapiRecip
Reserved As Long
RecipClass As Long
Name As String
Address As String
EIDSize As Long
EntryID As String
End Type
Private Type MapiFile
Reserved As Long
Flags As Long
Position As Long
cPathName As String
FileName As String
FileType As String
End Type
Private Declare Function MAPILogon Lib "MAPI32.DLL" _
(ByVal UIParam&, ByVal User$, ByVal Password$, ByVal Flags&, _
ByVal Reserved&, Session&) As Long
Private Declare Function MAPILogoff Lib "MAPI32.DLL" _
(ByVal Session&, ByVal UIParam&, ByVal Flags&, ByVal Reserved&) As Long
Private Declare Function MAPISendMail Lib "MAPI32.DLL" _
Alias "BMAPISendMail" (ByVal Session&, ByVal UIParam&, _
Message As MAPIMessage, Recipient() As MapiRecip, _
File() As MapiFile, ByVal Flags&, ByVal Reserved&) As Long
Private Declare Function MAPISendDocuments Lib "MAPI32.DLL" _
(ByVal UIParam&, ByVal DelimStr$, ByVal FilecPaths$, _
ByVal FileNames$, ByVal Reserved&) As Long
Private Sub btnSend_Click()
Dim l As Long
Dim lngSession As Long
Dim udtMessage As MAPIMessage
Dim strSubject As String
Dim strBody As String
strSubject = "Mapi Problem"
strBody = “in Outlook XP, 2003“
ReDim aryRecipient(0) As MapiRecip
aryRecipient(0).Name = “smtg@microsoft.com”
aryRecipient(0).Address = “smtg@microsoft.com”
aryRecipient(0).RecipClass = MAPI_TO
ReDim aryFile(0) As MapiFile
With aryFile(0)
.FileName = “C:\Windows\Notepad.exe”
.cPathName = “C:\Windows\Notepad.exe”
.Position = Len(strBody) - 1
.FileType = ""
.Reserved = 0
End With
With udtMessage
.Subject = strSubject
.NoteText = strBody
.Flags = 0
.FileCount = 1
.RecipCount = 1
.Reserved = 0
.DateReceived = ""
.MessageType = ""
End With
l = MAPILogon(Me.hWnd, "", "", MAPI_LOGON_UI, 0, lngSession)
l = MAPISendMail(lngSession, Me.hWnd, udtMessage, aryRecipient, aryFile, _ MAPI_DIALOG, 0)
l = MAPILogoff(lngSession, 0, 0, 0)
End Sub
__________________________ __________ __________ __________ __________ _________
Local machine running XPpro and using smtp email account as default. My application utlizes a custom form MS Outlook Form.
The following code works with no problem for Outlook 2000, meaning that it opens a new MailItem Form with the info, and after clicking send it puts the message in outbox…and it can be sent (Outlook 2000 in Internet Mode).
Now the problems appear in Outlook 2002 and 2003. It also creates the MailItem Form with the info, when I send the meassge, it moves from the outbox to the inbox as undelverable mail. When I look at email properties in the message form the E-mail Type field is the same the email address - with internet type defaulted. When I click on internet type button the E-mail Type field changes to SMTP, with this change, I can send the email, and it goes out with any problems. Like wise when I try to email in the standard manner, open contact dclick on the email address (btw: here it's defaulted to smtp) create and send an email.
So how do I set E-mail Type from MAPI, what am I missing here … if someone encountered this and has a workaround or knows what’s causing this (maybe how to set the transport protocol settings) or whatever - appreciate your taking time in responding to this.
Not sure at this point if it's local settings, Custom form settings or MAPI code, the idea here is that code should adopt the clients default email settings and email should go out without any manual changes or errors.
Thanks.
_________________________C
Private Type MAPIMessage
Reserved As Long
Subject As String
NoteText As String
MessageType As String
DateReceived As String
ConversationID As String
Flags As Long
RecipCount As Long
FileCount As Long
End Type
Private Type MapiRecip
Reserved As Long
RecipClass As Long
Name As String
Address As String
EIDSize As Long
EntryID As String
End Type
Private Type MapiFile
Reserved As Long
Flags As Long
Position As Long
cPathName As String
FileName As String
FileType As String
End Type
Private Declare Function MAPILogon Lib "MAPI32.DLL" _
(ByVal UIParam&, ByVal User$, ByVal Password$, ByVal Flags&, _
ByVal Reserved&, Session&) As Long
Private Declare Function MAPILogoff Lib "MAPI32.DLL" _
(ByVal Session&, ByVal UIParam&, ByVal Flags&, ByVal Reserved&) As Long
Private Declare Function MAPISendMail Lib "MAPI32.DLL" _
Alias "BMAPISendMail" (ByVal Session&, ByVal UIParam&, _
Message As MAPIMessage, Recipient() As MapiRecip, _
File() As MapiFile, ByVal Flags&, ByVal Reserved&) As Long
Private Declare Function MAPISendDocuments Lib "MAPI32.DLL" _
(ByVal UIParam&, ByVal DelimStr$, ByVal FilecPaths$, _
ByVal FileNames$, ByVal Reserved&) As Long
Private Sub btnSend_Click()
Dim l As Long
Dim lngSession As Long
Dim udtMessage As MAPIMessage
Dim strSubject As String
Dim strBody As String
strSubject = "Mapi Problem"
strBody = “in Outlook XP, 2003“
ReDim aryRecipient(0) As MapiRecip
aryRecipient(0).Name = “smtg@microsoft.com”
aryRecipient(0).Address = “smtg@microsoft.com”
aryRecipient(0).RecipClass
ReDim aryFile(0) As MapiFile
With aryFile(0)
.FileName = “C:\Windows\Notepad.exe”
.cPathName = “C:\Windows\Notepad.exe”
.Position = Len(strBody) - 1
.FileType = ""
.Reserved = 0
End With
With udtMessage
.Subject = strSubject
.NoteText = strBody
.Flags = 0
.FileCount = 1
.RecipCount = 1
.Reserved = 0
.DateReceived = ""
.MessageType = ""
End With
l = MAPILogon(Me.hWnd, "", "", MAPI_LOGON_UI, 0, lngSession)
l = MAPISendMail(lngSession, Me.hWnd, udtMessage, aryRecipient, aryFile, _ MAPI_DIALOG, 0)
l = MAPILogoff(lngSession, 0, 0, 0)
End Sub
__________________________
ASKER
Jim,
Sorry, those didn't help. I have looked all over the web and several forums...really bizarre...no references or answers anywhere...what could be the problem?
I'll try to explain again:
In outlook 2002, open a conatct form, click on the email address for the contact and the email properties from should pop-up. The third item is "email Type". By default, the email type is SMPT for my default acount and I can send mail with no problems.
When I use my mapi code, the email doen't go out and I get an undeliverable message "none of your accounts could send this message. When i check the 'email type' in the email properties from the Message from (same form as above) by clicking on the address, the 'Email Type' is set to Internet type. When I click on the internet type button and the value changes to SMTP, I can send the email without any problem.
My Question is this: Why is this not defaulting to my Default settings? How can I make it do that?
Is it in the Mapi code, a local setting or what?
Really appreciate any help you can Offer.
Thanks.
Sorry, those didn't help. I have looked all over the web and several forums...really bizarre...no references or answers anywhere...what could be the problem?
I'll try to explain again:
In outlook 2002, open a conatct form, click on the email address for the contact and the email properties from should pop-up. The third item is "email Type". By default, the email type is SMPT for my default acount and I can send mail with no problems.
When I use my mapi code, the email doen't go out and I get an undeliverable message "none of your accounts could send this message. When i check the 'email type' in the email properties from the Message from (same form as above) by clicking on the address, the 'Email Type' is set to Internet type. When I click on the internet type button and the value changes to SMTP, I can send the email without any problem.
My Question is this: Why is this not defaulting to my Default settings? How can I make it do that?
Is it in the Mapi code, a local setting or what?
Really appreciate any help you can Offer.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I might be being really dense here but I can't find this 'Email type' setting anywhere in the Mail options, properties, or from address properties...
Do a small test:
MsgBox ActiveInspector.CurrentIte
MsgBox ActiveInspector.CurrentIte
before and after you manually set the 'Email type' (you may have to save the mail first). Maybe these values will be different and you can use that...
J.