Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have the below VB code and i wanted to convert for C#. I tried many in website for the conversion but still getting errors.

Basically this code in ACTIVE X tool and i wanted to replace with SCRIPT TASK so need to convert to c#.
Please am in need of Help.
Function Main()

Dim sFrom
Dim sTo
Dim sCc
Dim sSubject
Dim sTextBody
Dim sAttach
Dim objMail
Dim iMsg
Dim iConf
Dim Flds

Const cdoSendUsingPort = 2

'MsgBox DTSGlobalVariables("Connection_EHSDW").Value


Set cn = CreateObject("ADODB.Connection")
cn.Open DTSGlobalVariables("Connection_EHSDW").Value
Set rs = cn.Execute("SELECT mail_from, mail_to, mail_cc, mail_subject, textbody, attachment_path FROM t_wims_mailing_list WHERE module = 'Claims' and task = 'Daily Claims Summary'" )
    
If Not rs.EOF Then
 sTo =  rs("mail_to")
 sCc = rs("mail_cc")
        sFrom = rs("mail_from")
 sSubject = rs("mail_subject")
 sTextBody = rs("textbody")
 sAttach = rs("attachment_path")
End If

set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = _
cdoSendUsingPort

.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"mailserv.mmm.com"
.Update

End With

iMsg.configuration = iConf
iMsg.To = sTo
iMsg.From = sFrom
iMsg.Subject = sSubject
iMsg.TextBody = sTextBody
iMsg.AddAttachment sAttach
iMsg.Send

Set objMail = Nothing
Set oRS = Nothing

Main = DTSTaskExecResult_Success

End Function
Posted
Updated 28-Mar-13 4:45am
v3
Comments
[no name] 28-Mar-13 10:31am    
Okay so since CodeProject is not a code translation service.... what specific issue is giving you trouble?

1 solution

Here you go:

Click me![^]
 
Share this answer
 
Comments
Biodude Basava 28-Mar-13 10:25am    
This is the reslt..."An error occured converting your code, probably due to a syntax error: -- line 1 col 1: EOF expected"
Richard C Bishop 28-Mar-13 10:30am    
Odd, is this VB.Net code? I have never seen that message before.
[no name] 28-Mar-13 10:38am    
Looks more like VBScript.
Richard C Bishop 28-Mar-13 10:41am    
I think you are right. In that case, there is not a direct conversion I don't think.
Biodude Basava 28-Mar-13 10:43am    
I had this code in active X scropt and i should replace with Script task...if its not working..do i have any other ways to fix this issue??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900