|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
HTML Emailseem to get this working using COM Interop. System.Web.Main doesn't seem allow for embedded graphics. Any ideas? I would really like to role my own rather than purchasing a 3rd party library. Tageting a windows forms application in c#. Have attached the old VB6 code as an example. thanks, >>>> Private Sub sendMessage(messageTo As String, messageFrom As String,messageSubject As String, messageBody As String, errorInfo As String, ClientID As Long) Dim iMsg As New cdo.Message Dim iConf As New cdo.Configuration Dim Flds As ADODB.Fields Set Flds = iConf.Fields Flds(cdoSendUsingMethod) = cdoSendUsingPort Flds(cdoSMTPServer) = "localhost" Flds(cdoSMTPServerPort) = 25 Flds(cdoSMTPConnectionTimeout) = 30 Flds(cdoSendUserReplyEmailAddress) = txtFrom Flds(cdoSendEmailAddress) = txtFrom Flds.Update Set iMsg.Configuration = iConf iMsg.To = messageTo iMsg.subject = messageSubject iMsg.AutoGenerateTextBody = True iMsg.TextBody = messageBody iMsg.CreateMHTMLBody txtHTMLurl, cdoSuppressNone iMsg.Send Hi Andrew,
Create an interop assembly for the CDO library used by the VB6 code, reference it from your C# project and then just port the VB code to C#. P.S. You will have to create an interop assembly for ADODB as well. -- Show quoteHide quoteSincerely, Dmitriy Lapshin [C# / .NET MVP] Bring the power of unit testing to the VS .NET IDE today! http://www.x-unity.net/teststudio.aspx "Andrew Robinson" <nemoby@nospam.nospam> wrote in message news:egZuKQhDFHA.960@TK2MSFTNGP09.phx.gbl... >I used to use CDO to send HTML embedded emails (including images). I can't > seem to get this working using COM Interop. System.Web.Main doesn't seem > allow for embedded graphics. Any ideas? I would really like to role my own > rather than purchasing a 3rd party library. > > Tageting a windows forms application in c#. Have attached the old VB6 code > as an example. > > thanks, > > >>>>> > > Private Sub sendMessage(messageTo As String, messageFrom As String, > messageSubject As String, messageBody As String, errorInfo As String, > ClientID As Long) > Dim iMsg As New cdo.Message > Dim iConf As New cdo.Configuration > Dim Flds As ADODB.Fields > Set Flds = iConf.Fields > > Flds(cdoSendUsingMethod) = cdoSendUsingPort > Flds(cdoSMTPServer) = "localhost" > Flds(cdoSMTPServerPort) = 25 > Flds(cdoSMTPConnectionTimeout) = 30 > Flds(cdoSendUserReplyEmailAddress) = txtFrom > Flds(cdoSendEmailAddress) = txtFrom > Flds.Update > > Set iMsg.Configuration = iConf > > iMsg.To = messageTo > iMsg.subject = messageSubject > iMsg.AutoGenerateTextBody = True > iMsg.TextBody = messageBody > iMsg.CreateMHTMLBody txtHTMLurl, cdoSuppressNone > iMsg.Send > > > Hi Dmitriy,
No sure whether the problem is something incorrect when you interop call your vb6 COM dll. Can you correctly use CDO component directly to send mail in .net application through COM interop? From my local test , I can successfully use CDO to send html mails with embeded images in a winform app. Here is the test code: ========================= private void btnSendCDO_Click(object sender, System.EventArgs e) { try { CDO.Message msg = new CDO.MessageClass(); msg.To = txtEmail.Text; msg.Subject = "Test Image Mail"; msg.From = "Alaindel***@gmail.com"; msg.CreateMHTMLBody("http://www.asp.net",CDO.CdoMHTMLFlags.cdoSuppressNone," ",""); CDO.Configuration config = new CDO.ConfigurationClass(); ADODB.Fields fields = null; fields = config.Fields; ADODB.Field field = null; field = fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]; field.Value = 1; field = fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]; field.Value = CDO.CdoPostUsing.cdoPostUsingPort; field = fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"]; field .Value = "smtphost"; fields.Update(); msg.Configuration = config; msg.Send(); msg = null; config = null; fields = null; field = null; } catch(Exception ex) { MessageBox.Show(ex.ToString()); } } ===================================== HTH. Thanks & Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
Other interesting topics
Deadlock Problem
MSDN Exception Documentation PropertyGrid sees only public properties Killing a thread started with delegate.BeginInvoke() DataAdapter & SQLClient Error Spawning Process from ASP.NET Capturing unhandled exceptions http/1.1 500 Program error cordbg.exe 0x2 C# Pocket PC and .NET framework |
|||||||||||||||||||||||