General_GSpot
asked on
Code created with Visual Basic not working on Vb.net
When I use these two bits of code that were created in Visual basic 2010, they work fine. When I try to create the same thing in Visual studio VB.net, most of it is unrecognized.
I'm Imported Visual basic and forms, but it seems that some parts do not work.
What am I missing, or can the code even be used between the two.
thanks
I'm Imported Visual basic and forms, but it seems that some parts do not work.
What am I missing, or can the code even be used between the two.
thanks
'End If
Dim file As String = folder.ToString
If ListView1.SelectedItems.Count > 0 Then
Dim lv1 As ListViewItem = ListView1.SelectedItems(0)
Dim filename As String = file & "\" & lv1.Text
Dim msg As MapiMessage = MapiMessage.FromFile(filename)
txtFrom.Text = msg.SenderName
txtSenderAddress.Text = msg.SenderEmailAddress
txtSubject.Text = msg.Subject
txtCC.Text = msg.DisplayCc
txtBody.Text = msg.Body
End If
End Sub
Private Sub btnOutlook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOutlook.Click
Dim folder As String = CStr(TreeView1.SelectedNode.Tag)
Dim file As String = folder.ToString
If ListView1.SelectedItems.Count > 0 Then
Dim lvO As ListViewItem = ListView1.SelectedItems(0)
Dim filename As String = file & "\" & lvO.Text
Dim msg As MapiMessage = MapiMessage.FromFile(filename)
Process.Start(Path.Combine("outlook.exe", filename))
End If
End Sub
which part is not recognized? what is the other version of VB.net you are trying to copy your code to? have you added a reference to MapiMessage (check your VS2010 project to see what DLL it is)?
ASKER
Well, in Vb.net 2008, under listview, it doesn't recognize 'selecteditems' just items. Also, the process.start(combine.path ()) doesn't work, where Visual Basic it works fine.
Mapimessage does work, as both can use and recognize the Aspose network DLL. I am able to programatically load one message into text boxes, but I can't get the listview to work properly,so I can't scroll through messages.
OK, so I used Visual Basic Express 2010 to make the original content that works fine, but then i wanted to use the same thing with Visual Studio 2008 to combine all of my little programs into one big one, to be used on our intranet.
I am pretty novice, third week programming :) Any help would be greatly appreciated.
Mapimessage does work, as both can use and recognize the Aspose network DLL. I am able to programatically load one message into text boxes, but I can't get the listview to work properly,so I can't scroll through messages.
OK, so I used Visual Basic Express 2010 to make the original content that works fine, but then i wanted to use the same thing with Visual Studio 2008 to combine all of my little programs into one big one, to be used on our intranet.
I am pretty novice, third week programming :) Any help would be greatly appreciated.
for Path, add "Imports System.IO" at the top of your form.
ASKER
I already have it there. That's what's bugging me.
SelectedItems should be recognized. Are you sure ListView1 exist and is a listview control?
this line is not valid (surely not work in VS2010):
Process.Start(Path.Combine ("outlook. exe", filename))
Should be only:
Process.Start("outlook.exe ", filename)
Process.Start(Path.Combine
Should be only:
Process.Start("outlook.exe
ASKER
OK, here is the one problem i'm having that I remember. Under the components, I have a listview for UI.webcontrols, and one for windows forms. If I uncheck the UI.Webcontrols, I can't see a listview at all. How do I tell the system to use the listview for Forms?
I thjink that is the proble, correct?
I thjink that is the proble, correct?
is your VS2010 a Windows or web project? it really looks like a Windows project. All the methods are not available for web controls.
also are you aware that Process.Start will start the process (outlook) on your server?
also are you aware that Process.Start will start the process (outlook) on your server?
ASKER
No the VS is a web project.
I did not know this. How can I start outlook locally and open that file. Is that even possible with a web project? On teh visual basic program, it opens outlook locally, it has to, outlook isn't even on the server.
I did not know this. How can I start outlook locally and open that file. Is that even possible with a web project? On teh visual basic program, it opens outlook locally, it has to, outlook isn't even on the server.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK, thanks, I will check into this.
ASKER
Pointed me in right direction, but still need a bit more help.
ASKER
I know I closed this, but here is my code transferred over to VS, thanks to you, I got the listview working but....
Now, it doesn't recognize the Nodes, actually it tells me it can't be a UI.Web.control, but as you can see, I dim'd it a form. What am I doing wrong here. (BTW, this will load the msg files, and then I'll use the process.start)
thanks.
Imports System.IO
Imports Aspose.Network.Outlook
Imports mscomctl
Partial Class EmailFinder
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim listview1 As Windows.Forms.ListView
Dim treeview1 As Windows.Forms.TreeView
Dim treenode As Windows.Forms.TreeNode
Dim FolderPath As String = "c:\jobs\emails"
Dim view As Windows.Forms.ListViewItem
Dim Tnode As Windows.Forms.TreeNode = treeview1.Nodes.Add("(Drive c:)")
'AddAllFolders(Tnode, "c:\jobs\emails")
AddAllFolders(Tnode, FolderPath)
listview1.View = Windows.Forms.View.Details
listview1.Columns.Add("filename", 150, Windows.Forms.HorizontalAlignment.Left)
listview1.Columns.Add("Date", 150, Windows.Forms.HorizontalAlignment.Left)
End Sub
Private Sub AddAllFolders(ByVal Tnode As TreeNode, ByVal FolderPath As String)
Try
For Each FolderNode As String In Directory.GetDirectories(FolderPath)
Dim SubFolderNode As TreeNode = Tnode.Nodes.Add(FolderNode.Substring(FolderNode.LastIndexOf("\"c) + 1))
SubFolderNode.Tag = FolderNode
SubFolderNode.Nodes.Add("Loading...")
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
Now, it doesn't recognize the Nodes, actually it tells me it can't be a UI.Web.control, but as you can see, I dim'd it a form. What am I doing wrong here. (BTW, this will load the msg files, and then I'll use the process.start)
thanks.
I can't help you much since you are now in a web project. also a web project should never have references to Windows Forms controls (windows.forms.view.detail s, Windows.Forms.HorizontalAl ignment, Windows.Forms.TreeNode, Windows.Forms.ListView, ...)
ASKER
OK, thanks.