LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: "Cannot convert string in Any variable" Date: Fri Nov 7 10:53:06 2008 Subject: Re: Bruce Armstrong's SMTP CCW example
> Try string (lower case) rather than String (leading cap). > > public string sendMail() > > String (leading cap) is a .Net system class: > http://msdn.microsoft.com/en-us/library/system.string.aspx > > string (lower case) is a simple text string: > http://msdn.microsoft.com/en-us/library/362314fe.aspx > > Isn't .Net fun? > > <Aron Cox> wrote in message > > news:48738c23.6263.1681692777@sybase.com... Hi, I need > > to call a .NET assembly from PB 10.5. I found Bruce > > Armstrong's SMTP example on Codexhange, downloaded it > and it worked, I can send emails via SMTP in .NET, great. > > > However I did a simple thing, changed the 'public > > void' to a 'public String' and returned a string after > > sending the email. I am unable to get that to work, and > > in fact can't get any data back in this way or by > > querying the objects, i.e. 'ls_var = ole_obj.var1' even > > though I can set them (lole_smtp.var1 = "xyz") fine. I > > can set data but not get it. > > > > Does anyone have any ideas as to whether this is > > possible, and if it is what I'm doing wrong? Here's my > code: > > > .NET Code ===> > > using System; > > using System.Collections.Generic; > > using System.Text; > > using System.Net.Mail; > > > > namespace DotNetSMTP > > { > > public class DotNetSMTP > > { > > private String senderName; > > > > public String SenderName > > { > > get { return senderName; } > > set { senderName = value; } > > } > > private String senderEmail; > > public String SenderEmail > > { > > get { return senderEmail; } > > set { senderEmail = value; } > > } > > private String smtpServer; > > public String SmtpServer > > { > > get { return smtpServer; } > > set { smtpServer = value; } > > } > > private String recipientEmail; > > public String RecipientEmail > > { > > get { return recipientEmail; } > > set { recipientEmail = value; } > > } > > private String subject; > > public String Subject > > { > > get { return subject; } > > set { subject = value; } > > } > > private String ccEmail = ""; > > public String CcEmail > > { > > get { return ccEmail; } > > set { ccEmail = value; } > > } > > private String bccEmail = ""; > > public String BccEmail > > { > > get { return bccEmail; } > > set { bccEmail = value; } > > } > > private bool isHTML = false; > > public bool IsHTML > > { > > get { return isHTML; } > > set { isHTML = value; } > > } > > private String messageText; > > public String MessageText > > { > > get { return messageText; } > > set { messageText = value; } > > } > > public String sendMail() > > { > > SmtpClient smtpClient = new SmtpClient(); > > MailMessage message = new MailMessage(); > > > > MailAddress fromAddress = new > > MailAddress(senderEmail, senderName); > > smtpClient.Host = smtpServer; > > smtpClient.Port = 25; > > message.From = fromAddress; > > message.To.Add(recipientEmail); > > message.Subject = subject; > > if (!ccEmail.Equals("")) > > { > > message.CC.Add(ccEmail); > > } > > if (!bccEmail.Equals("")) > > { > > message.Bcc.Add(ccEmail); > > } > > message.IsBodyHtml = isHTML; > > message.Body = messageText; > > > > System.Net.NetworkCredential > > basicAuthentication = new > > System.Net.NetworkCredential("<mylogin>", > > "<mypassword>"); > > smtpClient.UseDefaultCredentials = false; > smtpClient.Credentials = basicAuthentication; > > > smtpClient.Send(message); > > > > return "Hooray"; > > > > } > > } > > } > > > > > > PB Code ==> > > > > ls_string = lole_smtp.SendMail() > > > > Error message ==> > > Fails with 'Cannot convert string in any variable to > > string' (something like that anyway). > >
| Navigate in group sybase.public.powerbuilder.ole-ocx-activex at sever forums.sybase.com | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by Zareef Ahmed
Powered By PHP Consultants |