Note that there are some explanatory texts on larger screens.

plurals
  1. POConvert vb.net to C# in SSIS script task
    primarykey
    data
    text
    <p>I want to convert the following vb.net script into C#.net script in SSIS Script task. I tried converting using Developer Fusion but iam getting lots of errors.Can some one help me.My Vb.net script:</p> <pre><code> Public Sub GetAttachments() Dim myolApp As Outlook.Application Dim ns As Outlook.NameSpace Dim Inbox As MAPIFolder Dim Item As Object Dim Atmt As Attachment Dim FileName As String Dim subject As String Dim AttachmentName As String Dim Body As String Dim SenderName As String Dim SenderEmailAddress As String Dim CreationTime As String Dim i As Integer Dim j As Integer On Error GoTo GetAttachments_err myolApp = CreateObject("Outlook.Application") ns = myolApp.GetNamespace("MAPI") ns.Logon("", "", False, True) Inbox = ns.Folders("Mailbox - name").Folders("Inbox") i = 0 j = 1 'Scan for attachments For Each Item In Inbox.Items() System.Windows.Forms.Application.DoEvents() If (Item.UnRead) Then MessageBox.Show(j, "EMail Number") subject = DirectCast(Item, Microsoft.Office.Interop.Outlook.MailItem).Subject MessageBox.Show(subject, "E-Mail Subject") AttachmentName = DirectCast(Item, Microsoft.Office.Interop.Outlook.MailItem).Attachments(1).FileName Body = DirectCast(Item, Microsoft.Office.Interop.Outlook.MailItem).Body SenderEmailAddress = DirectCast(Item, Microsoft.Office.Interop.Outlook.MailItem).SenderEmailAddress SenderName = DirectCast(Item, Microsoft.Office.Interop.Outlook.MailItem).SenderName CreationTime = DirectCast(Item, Microsoft.Office.Interop.Outlook.MailItem).CreationTime.ToString() MessageBox.Show(AttachmentName, "Attachment Name") MessageBox.Show(Body, "Body") MessageBox.Show(SenderEmailAddress, "From Address") MessageBox.Show(SenderName, "From") MessageBox.Show(CreationTime, "Created Time") j = j + 1 If (SenderEmailAddress.ToLower = "lch@gmail.com".ToLower) Then MessageBox.Show("reading from") For Each Atmt In Item.Attachments FileName = "C:\Email Attachments\" &amp; Atmt.FileName Atmt.SaveAsFile(FileName) i = i + 1 Item.UnRead = True Next Atmt End If End If Next Item 'Display summary If i &gt; 0 Then MsgBox("I found " &amp; i &amp; " attached files." _ &amp; vbCrLf &amp; "I have saved them into the C:\Email Attachments folder." _ &amp; vbCrLf &amp; vbCrLf &amp; "Have a nice day.", vbInformation, "Finished!") Else MsgBox("I didn't find any attached files in your mail.", vbInformation, _ "Finished!") End If 'Clear Memory GetAttachments_exit: Atmt = Nothing Item = Nothing ns = Nothing Exit Sub 'Error Handler GetAttachments_err: MsgBox("An unexpected error has occurred." _ &amp; vbCrLf &amp; "Please note and report the following information." _ &amp; vbCrLf &amp; "Script Name: GetAttachments" _ &amp; vbCrLf &amp; "Error Number: " &amp; Err.Number _ &amp; vbCrLf &amp; "Error Description: " &amp; Err.Description _ &amp; vbCrLf &amp; "Error Line: " &amp; Err.Source _ , vbCritical, "Error!") Resume GetAttachments_exit 'End If End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload