Skip to main content

[archive] Problems with CobolMail and email.exe

  • March 29, 2004
  • 36 replies
  • 0 views

Show first post

36 replies

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
Attached you will find msmapi32.zip that contains msmapi32.cbl and msmapi32.def.

There are three spots you will have to change before you compile. Search the msmapi32.cbl for *Insert, and follow the instructions.

Now, to my experience, this program successfully sends en email with attachment using Outlook Express 6. With Outlook 2002 it sends the email, but refuses to attach the file. This *may* relate to some security scheme.

When you run this app. Be aware that Outlook Express and Outlook that has been enabled with the security patches will display a dialog asking if this is okay. I have learned the hard way that for some obscure reason, this dialog is invisible if you run in the debugger. In that case, select the invisble window (caption Outlook) from the status bar and press ENTER even though you cannot see it.

If you have time to provide me with some feedback on this, it is highly appreciated. Thanks.

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
I tested in on Win98 SE using Outlook Express and it worked for me! I will continue to test on other PC's/setups as time allows. But I don't have access to any version of Outlook > 2000 at the current time.

I also would like to try adding to it to allow multiple recipients, and potentially CC:, and BCC:. And also multiple attachments. I have some questions for anyone who is trying or has tried. Is the "human name" required? And is there a way to access the users address book? Anyone know of any good MSDN or other links with some helpful insight?

Thanks for the hard work again, Gisle!

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
I tested in on Win98 SE using Outlook Express and it worked for me! I will continue to test on other PC's/setups as time allows. But I don't have access to any version of Outlook > 2000 at the current time.

I also would like to try adding to it to allow multiple recipients, and potentially CC:, and BCC:. And also multiple attachments. I have some questions for anyone who is trying or has tried. Is the "human name" required? And is there a way to access the users address book? Anyone know of any good MSDN or other links with some helpful insight?

Thanks for the hard work again, Gisle!

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
I tested in on Win98 SE using Outlook Express and it worked for me! I will continue to test on other PC's/setups as time allows. But I don't have access to any version of Outlook > 2000 at the current time.

I also would like to try adding to it to allow multiple recipients, and potentially CC:, and BCC:. And also multiple attachments. I have some questions for anyone who is trying or has tried. Is the "human name" required? And is there a way to access the users address book? Anyone know of any good MSDN or other links with some helpful insight?

Thanks for the hard work again, Gisle!

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
I don't think you have to provide a "human name".

Good luck!

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
I have also tested this on Windows XP with Outlook Express, and it works fine too. I hope to soon be testing with W2000 and versions of Outlook.
And if anyone has any useful links to Microsoft's developer site or elsewhere on how to do CC:, or BCC:, or multiple attachments, I am looking to develop this further and will post any successes.

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
RSoftcheck,
the attched is a part of vb codes i use to send emails... it can do cc, bcc as well as multiple attachments. for multiple attachments, in "EmailAttachment1" string, separate filenames by ";"
i hope you can translate these to cobol.

Private Sub SendByOutlook()
Dim a As Boolean
Dim ol As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim newMail As Outlook.MailItem

'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace("MAPI")

'Create a new mail message item.
Set newMail = ol.CreateItem(olMailItem)
With newMail
'Add the subject of the mail message.
.Subject = Trim(EmailSubject)
'Create some body text.
.Body = Trim(EmailBodyOfMessage) & vbCrLf
'Add a recipient and test to make sure that the
'address is valid using the Resolve method.
With .Recipients.Add(ToEmailAddress)
.Type = olTo
'If Not .Resolved Then
' MsgBox "Unable to resolve TO address.", vbInformation
' Exit Sub
'End If
End With
'Add CC Recipients
If Len(CCEmailAddress) <> 0 Then
With .Recipients.Add(CCEmailAddress)
.Type = olCC
'If Not .Resolved Then
' MsgBox "Unable to resolve CC address.", vbInformation
' Exit Sub
'End If
End With
End If
'Add BCC Recipients
If Len(BCCEmailAddress) <> 0 Then
With .Recipients.Add(BCCEmailAddress)
.Type = olBCC
'If Not .Resolve Then
' MsgBox "Unable to resolve BCC address.", vbInformation
' Exit Sub
'End If
End With
End If
'Senders Name
'.SentOnBehalfOfName = FromName
'Attach attachments.
If Len(EmailAttachment1) <> 0 Then
With .Attachments.Add(Source:=EmailAttachment1, Position:=1)
End With
End If
'Do not save them in Sent Folder
.DeleteAfterSubmit = True
'Send the mail message.
.Send
End With

'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
End Sub

Private Sub SendByMAPI()

Dim iIndex As Integer

frmSendMailSMTP.MAPISession1.SignOn
frmSendMailSMTP.MAPIMessages1.SessionID = frmSendMailSMTP.MAPISession1.SessionID
frmSendMailSMTP.MAPIMessages1.Compose
frmSendMailSMTP.MAPIMessages1.MsgNoteText = EmailBodyOfMessage
frmSendMailSMTP.MAPIMessages1.RecipDisplayName = ToName

iIndex = 0

frmSendMailSMTP.MAPIMessages1.RecipIndex = iIndex
frmSendMailSMTP.MAPIMessages1.RecipAddress = ToEmailAddress
frmSendMailSMTP.MAPIMessages1.RecipType = 1
frmSendMailSMTP.MAPIMessages1.AddressResolveUI = False
frmSendMailSMTP.MAPIMessages1.ResolveName

If Len(CCEmailAddress) <> 0 Then
iIndex = iIndex 1
frmSendMailSMTP.MAPIMessages1.RecipIndex = iIndex
frmSendMailSMTP.MAPIMessages1.RecipAddress = CCEmailAddress
frmSendMailSMTP.MAPIMessages1.RecipType = 2
frmSendMailSMTP.MAPIMessages1.AddressResolveUI = False
frmSendMailSMTP.MAPIMessages1.ResolveName
End If

If Len(BCCEmailAddress) <> 0 Then
iIndex = iIndex 1
frmSendMailSMTP.MAPIMessages1.RecipIndex = iIndex
frmSendMailSMTP.MAPIMessages1.RecipAddress = BCCEmailAddress
frmSendMailSMTP.MAPIMessages1.RecipType = 3
frmSendMailSMTP.MAPIMessages1.AddressResolveUI = False
frmSendMailSMTP.MAPIMessages1.ResolveName
End If

frmSendMailSMTP.MAPIMessages1.MsgSubject = EmailSubject
If Len(EmailAttachment1) <> 0 Then
frmSendMailSMTP.MAPIMessages1.AttachmentIndex = 0
frmSendMailSMTP.MAPIMessages1.AttachmentPosition = 0
frmSendMailSMTP.MAPIMessages1.AttachmentPathName = EmailAttachment1
End If
frmSendMailSMTP.MAPIMessages1.Send
frmSendMailSMTP.MAPISession1.SignOff

DoEvents

On Error GoTo 0

Exit Sub

End Sub

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
RSoftcheck,
the attched is a part of vb codes i use to send emails... it can do cc, bcc as well as multiple attachments. for multiple attachments, in "EmailAttachment1" string, separate filenames by ";"
i hope you can translate these to cobol.

Private Sub SendByOutlook()
Dim a As Boolean
Dim ol As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim newMail As Outlook.MailItem

'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace("MAPI")

'Create a new mail message item.
Set newMail = ol.CreateItem(olMailItem)
With newMail
'Add the subject of the mail message.
.Subject = Trim(EmailSubject)
'Create some body text.
.Body = Trim(EmailBodyOfMessage) & vbCrLf
'Add a recipient and test to make sure that the
'address is valid using the Resolve method.
With .Recipients.Add(ToEmailAddress)
.Type = olTo
'If Not .Resolved Then
' MsgBox "Unable to resolve TO address.", vbInformation
' Exit Sub
'End If
End With
'Add CC Recipients
If Len(CCEmailAddress) <> 0 Then
With .Recipients.Add(CCEmailAddress)
.Type = olCC
'If Not .Resolved Then
' MsgBox "Unable to resolve CC address.", vbInformation
' Exit Sub
'End If
End With
End If
'Add BCC Recipients
If Len(BCCEmailAddress) <> 0 Then
With .Recipients.Add(BCCEmailAddress)
.Type = olBCC
'If Not .Resolve Then
' MsgBox "Unable to resolve BCC address.", vbInformation
' Exit Sub
'End If
End With
End If
'Senders Name
'.SentOnBehalfOfName = FromName
'Attach attachments.
If Len(EmailAttachment1) <> 0 Then
With .Attachments.Add(Source:=EmailAttachment1, Position:=1)
End With
End If
'Do not save them in Sent Folder
.DeleteAfterSubmit = True
'Send the mail message.
.Send
End With

'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
End Sub

Private Sub SendByMAPI()

Dim iIndex As Integer

frmSendMailSMTP.MAPISession1.SignOn
frmSendMailSMTP.MAPIMessages1.SessionID = frmSendMailSMTP.MAPISession1.SessionID
frmSendMailSMTP.MAPIMessages1.Compose
frmSendMailSMTP.MAPIMessages1.MsgNoteText = EmailBodyOfMessage
frmSendMailSMTP.MAPIMessages1.RecipDisplayName = ToName

iIndex = 0

frmSendMailSMTP.MAPIMessages1.RecipIndex = iIndex
frmSendMailSMTP.MAPIMessages1.RecipAddress = ToEmailAddress
frmSendMailSMTP.MAPIMessages1.RecipType = 1
frmSendMailSMTP.MAPIMessages1.AddressResolveUI = False
frmSendMailSMTP.MAPIMessages1.ResolveName

If Len(CCEmailAddress) <> 0 Then
iIndex = iIndex 1
frmSendMailSMTP.MAPIMessages1.RecipIndex = iIndex
frmSendMailSMTP.MAPIMessages1.RecipAddress = CCEmailAddress
frmSendMailSMTP.MAPIMessages1.RecipType = 2
frmSendMailSMTP.MAPIMessages1.AddressResolveUI = False
frmSendMailSMTP.MAPIMessages1.ResolveName
End If

If Len(BCCEmailAddress) <> 0 Then
iIndex = iIndex 1
frmSendMailSMTP.MAPIMessages1.RecipIndex = iIndex
frmSendMailSMTP.MAPIMessages1.RecipAddress = BCCEmailAddress
frmSendMailSMTP.MAPIMessages1.RecipType = 3
frmSendMailSMTP.MAPIMessages1.AddressResolveUI = False
frmSendMailSMTP.MAPIMessages1.ResolveName
End If

frmSendMailSMTP.MAPIMessages1.MsgSubject = EmailSubject
If Len(EmailAttachment1) <> 0 Then
frmSendMailSMTP.MAPIMessages1.AttachmentIndex = 0
frmSendMailSMTP.MAPIMessages1.AttachmentPosition = 0
frmSendMailSMTP.MAPIMessages1.AttachmentPathName = EmailAttachment1
End If
frmSendMailSMTP.MAPIMessages1.Send
frmSendMailSMTP.MAPISession1.SignOff

DoEvents

On Error GoTo 0

Exit Sub

End Sub

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
RSoftcheck,
the attched is a part of vb codes i use to send emails... it can do cc, bcc as well as multiple attachments. for multiple attachments, in "EmailAttachment1" string, separate filenames by ";"
i hope you can translate these to cobol.

Private Sub SendByOutlook()
Dim a As Boolean
Dim ol As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim newMail As Outlook.MailItem

'Return a reference to the MAPI layer.
Set ns = ol.GetNamespace("MAPI")

'Create a new mail message item.
Set newMail = ol.CreateItem(olMailItem)
With newMail
'Add the subject of the mail message.
.Subject = Trim(EmailSubject)
'Create some body text.
.Body = Trim(EmailBodyOfMessage) & vbCrLf
'Add a recipient and test to make sure that the
'address is valid using the Resolve method.
With .Recipients.Add(ToEmailAddress)
.Type = olTo
'If Not .Resolved Then
' MsgBox "Unable to resolve TO address.", vbInformation
' Exit Sub
'End If
End With
'Add CC Recipients
If Len(CCEmailAddress) <> 0 Then
With .Recipients.Add(CCEmailAddress)
.Type = olCC
'If Not .Resolved Then
' MsgBox "Unable to resolve CC address.", vbInformation
' Exit Sub
'End If
End With
End If
'Add BCC Recipients
If Len(BCCEmailAddress) <> 0 Then
With .Recipients.Add(BCCEmailAddress)
.Type = olBCC
'If Not .Resolve Then
' MsgBox "Unable to resolve BCC address.", vbInformation
' Exit Sub
'End If
End With
End If
'Senders Name
'.SentOnBehalfOfName = FromName
'Attach attachments.
If Len(EmailAttachment1) <> 0 Then
With .Attachments.Add(Source:=EmailAttachment1, Position:=1)
End With
End If
'Do not save them in Sent Folder
.DeleteAfterSubmit = True
'Send the mail message.
.Send
End With

'Release memory.
Set ol = Nothing
Set ns = Nothing
Set newMail = Nothing
End Sub

Private Sub SendByMAPI()

Dim iIndex As Integer

frmSendMailSMTP.MAPISession1.SignOn
frmSendMailSMTP.MAPIMessages1.SessionID = frmSendMailSMTP.MAPISession1.SessionID
frmSendMailSMTP.MAPIMessages1.Compose
frmSendMailSMTP.MAPIMessages1.MsgNoteText = EmailBodyOfMessage
frmSendMailSMTP.MAPIMessages1.RecipDisplayName = ToName

iIndex = 0

frmSendMailSMTP.MAPIMessages1.RecipIndex = iIndex
frmSendMailSMTP.MAPIMessages1.RecipAddress = ToEmailAddress
frmSendMailSMTP.MAPIMessages1.RecipType = 1
frmSendMailSMTP.MAPIMessages1.AddressResolveUI = False
frmSendMailSMTP.MAPIMessages1.ResolveName

If Len(CCEmailAddress) <> 0 Then
iIndex = iIndex 1
frmSendMailSMTP.MAPIMessages1.RecipIndex = iIndex
frmSendMailSMTP.MAPIMessages1.RecipAddress = CCEmailAddress
frmSendMailSMTP.MAPIMessages1.RecipType = 2
frmSendMailSMTP.MAPIMessages1.AddressResolveUI = False
frmSendMailSMTP.MAPIMessages1.ResolveName
End If

If Len(BCCEmailAddress) <> 0 Then
iIndex = iIndex 1
frmSendMailSMTP.MAPIMessages1.RecipIndex = iIndex
frmSendMailSMTP.MAPIMessages1.RecipAddress = BCCEmailAddress
frmSendMailSMTP.MAPIMessages1.RecipType = 3
frmSendMailSMTP.MAPIMessages1.AddressResolveUI = False
frmSendMailSMTP.MAPIMessages1.ResolveName
End If

frmSendMailSMTP.MAPIMessages1.MsgSubject = EmailSubject
If Len(EmailAttachment1) <> 0 Then
frmSendMailSMTP.MAPIMessages1.AttachmentIndex = 0
frmSendMailSMTP.MAPIMessages1.AttachmentPosition = 0
frmSendMailSMTP.MAPIMessages1.AttachmentPathName = EmailAttachment1
End If
frmSendMailSMTP.MAPIMessages1.Send
frmSendMailSMTP.MAPISession1.SignOff

DoEvents

On Error GoTo 0

Exit Sub

End Sub

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
RSoftcheck,

Here is the code to use with MSMAPI32 to have multiple attachments included in your mail

           PERFORM VARYING FILE-IDX FROM 1 BY 1
           UNTIL FILE-IDX > NUMBER-OF-FILES
              INQUIRE MyMessage        AttachmentCount in AIndex
              MODIFY  MyMessage
                      AttachmentIndex    = AIndex
                      AttachmentPosition = FILE-IDX
                      AttachmentType     = mapData
                      AttachmentPathName = FILE-TO-SEND(FILE-IDX)
           END-PERFORM.



Concerning the CC & BCC properties, here's a link that discribe the process. Unfortunatly, I don't have code to use multiple CC's or BCC's but you have to change the RecipIndex and RecipType.



RecipIndex
RecipType

Kind regards

[Migrated content. Thread originally posted on 28 March 2004]

I have downloaded both of these and tried to use them with no success so far. The error I get on both is 15 - bad recipient type. I found on Microsoft's developers web site that the valid codes for a recipient are 1 for To:, 2 for CC:, and 3 for BCC:. I can't see where this is set in these programs though. Am I overlooking something too obvious? I am just using one of my own e-mail addresses, rscheck@edctechnology.com. I see where someone else had this same problem earler, but I could not find the resolution.
This would also be a nice feature if I could allow the person to copy or blind copy other recipients. Has anyone been able to find where on Microsoft's web site it explains this further?
Thanks to anyone who can point me in the right direction!
For what it is worth, I have been able to reproduce the behavior, I will see if I can find a solution to this.


Was this issue resolved? Would someone be able to provide the most current source copy of the MSMAPI32.ocx email program? I'm just starting to look into adding a simple email send with attachment and would greatly appreciate any help!

Thank you!