Hi,
I am stuck with a piece of code. Could you please help me out with the query.
I have a VB6.0 built com component which passes a collection type object to a c# dll. This collection VB6.0 is a collection of strings (paths as string for mail attachments).
VB6.0 call :
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim attachmentPath1 As String
Dim attachmentPath2 As String
attachmentPath1 = "C:\SMTPAttachmentsTest\TestAttachment1.txt"
attachmentPath2 = "C:\SMTPAttachmentsTest\TestAttachment2.txt"
attachmentColl.Add (attachmentPath1)
attachmentColl.Add (attachmentPath2)
'Call to c# dll
MailHelperSMTPObject.SendMailMessageWOAttachment from.Text, recipient.Text, recipient.Text, subject.Text, message.Text, attachmentColl
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
The c# code is supposed to catch the attachmentColl collection and read all the string paths in that collection.
C# Code :
public void SendMailMessageWOAttachment(string from, string to, string cc, string subject, string body, object AttachmentPaths)
{
string SMTPSrv;
Int32 SMTPPort;
MailMessage mMailMessage = new MailMessage();
mMailMessage.From = new MailAddress(from);
mMailMessage.To.Add(new MailAddress(to));
mMailMessage.CC.Add(new MailAddress(cc));
mMailMessage.Subject = subject;
mMailMessage.Body = body;
SmtpClient mSmtpClient = new SmtpClient(SMTPSrv);
mSmtpClient.Host = SMTPSrv;
mSmtpClient.Port = SMTPPort;
Attachment attach1;
foreach (object i in AttachmentPaths)
{
attach1 = new Attachment(i.ToString());
mMailMessage.Attachments.Add(attach1);
}
mSmtpClient.Send(mMailMessage);
}
The problem is that, I cannot change the VB code. I can change only c# code to catch the VB call. I have tried numerous combinations to catch the collection object from VB6.0 but unable to do so. The code works perfect when I remove the attachment collection object from VB6.0 code. But it give a a runtime error of Automation and interface or invalid argument or parameter call. I am using a callable wrapper.
Please help.