Problem using SmtpMail.Send() in a VB.NET dll with a C++ string 
Author Message
 Problem using SmtpMail.Send() in a VB.NET dll with a C++ string

I've writen a VC++ app that calls a VB.NET dll I wrote which executes an
SmtpMail.Send()

The VC++ app passes in the message's subject and body strings (standard char
arrays), which I've done many times before with other apps.  Everything
works fine, with one major exeption:

If/when my message body string contains any newline or carriage return
characters ('\n' or '\r'), the SmtpMail.Send() function will {*filter*}out with a
"Cannot access 'CDO.message' object" (or whatever the usual error is to that
effect).  If the body is just a one-line string, there's no problem and it
sends the mail just fine.

Looking at multi line strings passed in from within the Dll, the looks
correct and the line formatting is still as it should be, but I did also
notice that if I try to remove/replace the newline or carriage return
characters inside of the dll (using the Replace() string function with vbCr,
vbLf, vbCrLf) the string remains unchanged.

Does anyone have a clue as to why the the VB.NET dll seems to be having
difficulty manipulating/using line-formatted strings?  This has been driving
me insane.  For now the temporary fix is to just add the text as an
attachment file, but I'd really like to be able to have the text within the
message body.

Thanks,
-Scott



Mon, 18 Jul 2005 04:28:13 GMT  
 Problem using SmtpMail.Send() in a VB.NET dll with a C++ string

Quote:


> I've writen a VC++ app that calls a VB.NET dll I wrote which executes an
> SmtpMail.Send()

> The VC++ app passes in the message's subject and body strings (standard
char
> arrays), which I've done many times before with other apps.  Everything
> works fine, with one major exeption:

> If/when my message body string contains any newline or carriage return
> characters ('\n' or '\r'), the SmtpMail.Send() function will {*filter*}out
with a
> "Cannot access 'CDO.message' object" (or whatever the usual error is to
that
> effect).  If the body is just a one-line string, there's no problem and it
> sends the mail just fine.

> Looking at multi line strings passed in from within the Dll, the looks
> correct and the line formatting is still as it should be, but I did also
> notice that if I try to remove/replace the newline or carriage return
> characters inside of the dll (using the Replace() string function with
vbCr,
> vbLf, vbCrLf) the string remains unchanged.

> Does anyone have a clue as to why the the VB.NET dll seems to be having
> difficulty manipulating/using line-formatted strings?  This has been
driving
> me insane.  For now the temporary fix is to just add the text as an
> attachment file, but I'd really like to be able to have the text within
the
> message body.

> Thanks,
> -Scott

The SmtpMail.Send() function calls for String parameters.  Use wide
character strings.  Construct a String from each of the wide character
strings (wchar_t *) and pass that to the .dll.  My guess is there may be
some casting going awry.

If that doesn't pan out, can you send the code snippet you use to construct
the parameter(s) for SmtpMail.Send()?
--
Drew Hoskins, Visual C++ Team
This posting is provided AS IS with no warranties, and confers no rights.



Sun, 14 Aug 2005 03:03:17 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using vb.net classes in C++ Win32 DLLs

2. Howto make a dll in VC++ 6 to be used in VB 6 and VB .Net

3. Howto make a dll in VC++ 6 to be used in VB 6 and VB .Net

4. Howto make a dll in VC++ 6 to be used in VB 6 and VB .Net

5. Using VB.NET Class in C# without making as DLL

6. Using VB.Net Ctrl Library in Unmanaged C++

7. Instability when calling a C++ DLL from VB.NET

8. Problems Sending a copy of a class over the net using serialization

9. function parameters to pass a VB string array to a C++ DLL

10. passing Array of Strings between a C/C++ DLL and VB

11. Returning strings to vb from c++ dll

12. Calling C++ DLLs from VB with string params

 

 
Powered by phpBB® Forum Software