
masj78
Avatar/Signature-
Posts
31 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by masj78
-
Warning before using CDO! If needed I have a copy of the Outlook 98 cdo.dll that I can email. However I would think carefully before using CDO to build any email interfaces. The reason is that clever Microsoft introduced a security clause, which prevents access to address book and sender field. So if you need to get the From field in emails to use in your work or access to addresses in yours or others address books, its a no go. Would suggest using the other 2 forms of CDO, though I am not sure if they have sucome to the same fate and don't know how to use them myself.:mad:
-
Many Thanks for the advice. I have chosen to use the RTB methods, which has taken a fraction of the code and saves the files with no loss of formating: Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click SaveFileDialog1.Filter = "Text files(*.doc)|*.doc" SaveFileDialog1.ShowDialog() emailText.SaveFile(SaveFileDialog1.FileName,OpenMode.Output) End Sub cheers!
-
I have written a routine to save text from a RichTextBox to a file. The text is taken from Outlook and contains the original formating. However I am loosing the formating when saving it to a .TXT file and wondering if its possible to ajust my code to save it as a .DOC instead. (would save an extra cut and paste into Wordpad/Word or openwith ....) My code is as follows: SaveFileDialog1.Filter = "Text files(*.txt)|*.txt" SaveFileDialog1.ShowDialog() If SaveFileDialog1.FileName <> "" Then FileOpen(1, SaveFileDialog1.FileName, OpenMode.Output) PrintLine(1, RichTextBox1.Text) FileClose(1) End If Many Thanks!:rolleyes:
-
Cheers for the help, but still having problems. Both methods look logical. Passing reference in a method or constructor, but still gives a null system reference error. Damn! This is frustrating. In the first method, the line its complaining about is: Public objSomeMethods As SomeMethods = New SomeMethods(Me) In the second method, the line below is giving a syntax error as needing a declaration: SomeMethods.objForm1 = Me Hopefully we will get there somehow!
-
Many Thanks. Works Perfect! :)
-
I am trying to find a way of refreshing the listview contents when I press a button, but not having much joy. Have tried ListView.clear, but this takes away the columns and nothing is displayed. There is a refresh and update method, but not sure how to use these. Any Ideas!
-
Do you know the best way to do this? I know how to do it in Java Controller cObj = new Controller(this); Model mObj = new Model(this, cObj); Above in Java with 2 class instances Controller and Model; to link the model to controller you pass in an instance parameter of the controller into the model object.
-
I am new to VB.NET and unsure of the way this works. I have a form with a variety of controls and to keep things nice and neat I have written some sub routine methods in another class vb file for the form to perform. The class with the sub routine methods in has references to controls on the form. I assumed if you create a link as I have done below and the methods are public then I could reference the methods from the form class. However when I do it this way I get a null reference error and if I add new to the linking instances it gives me a stack overflow error. My code is as follows: Public Class Form1 Public objSomeMethods As SomeMethods objSomeMethods.method1() objSomeMethods.method2() End Class Public Class SomeMethods Public objForm1 As Form1 public Sub method1() objForm1.buttonaction End Sub Public Sub method2() objForm1.buttonaction End sub End Class Can someone explain the proper way of going about this as I am a bit confused. Many Thanks!
-
Well I am storing ordinary text in a notepad text file. Deleting the file and re-creating it is one solution that I will try, cheers! Ideally I need to read past the file till -1 and then backupspace to the start of the file.
-
Hi All, Does anyone know if its possible to delete the contents of a text file. I am using stream reader/writer to try and store program settings, and need some way of removing the settings already in place if the user decides to change them. cheers!:confused:
-
StreamReader/Split Function Problem!
masj78 replied to masj78's topic in Directory / File IO / Registry
Will do! Cheers! Didn't notice that! -
StreamReader/Split Function Problem!
masj78 replied to masj78's topic in Directory / File IO / Registry
A star yet again! Both methods work, although as you mentioned; method 2 is a bit neater. I had a feeling the Do Loop and until clause was a bit dodgy and the ReadToEnd function was only needed, but wasn't sure which of the 2 was the cause. Thanks again! -
I am using the Split Function to make a String array of the contence of a text file(array of words). I am reading the file using StreamReader. The problem occuring is that the first String object in the Array, which is the first word of the text file is missing its first letter. Example contence of the file is: This is a test! The 'This' word gets put into the first array position as 'his', and all the other words are complete with no letters missing. My code is as follows: Dim fileRead As New IO.StreamReader("C:\store.txt") Dim store As Array Do Until (fileRead.Read = -1) strRead = fileRead.ReadToEnd strRead.ToString() store = Split(strRead, " ", -1) Loop reading out store(0) gives 'his' Any ideas anyone!
-
cheers for that. In the end I used the mouse up control and a getter to obtain the field being clicked in the ListView and the .text property as you mentioned to get the contence of the field. Found the method on an example from the MSDN section of Microsofts site.
-
Displaying Contents of Inbox With ListView??
masj78 replied to masj78's topic in Interoperation / Office Integration
I have solved this in another forum. The ListView does not allow different variable types to co-exist together. The only variable type accepted is 'String'. The first item and subitem are both of type String. The 'time received' subitem I was trying to add is of type 'Variant'. What was needed was to cast it to a String, which is of course simple; As follows: .SubItems.Add(objMessage.TimeReceived.ToString) Job Done! -
Cheers Divil, Worked a treat, Brilliant!! Would it be possible to ask one more favour? Do you happen to know how I can retrieve the contents of the items; specifically the first column, depending on the one the user clicks on and other columns if possible. I have tried using the SelectedIndexChanged event and a call to the "listitems .Text" property but it just returns the last items text in the first column, no matter which item you click on. I know that some kind of index method is needed but cannot get my head round how it operates and havn't found any examples on here or anywhere else or in my books. Cheers!
-
I am using an Outlook COM library called CDO.dll to display Inbox messages. Turning on Option Strict seems to indicate I have lots of late binding. I have read up on this and being new to VB.NET I have no idea how to use the better suggested way of early binding. My code anyway that is giving me problems, which partially works with Option Explicit On is: Dim colMessages As MAPI.Messages Dim objMessage As MAPI.Message Dim lstStuff As New ListViewItem Dim count As Integer With ListView1.Items For Each objMessage In gobjSession.Inbox.Messages lstStuff = .Add(objMessage.Size) With lstStuff .SubItems.Add(objMessage.Subject) .SubItems.Add(objMessage.TimeReceived) ' error occurs if add this line End With Next End With End Sub cheers!
-
Does anyone know how to get the sender of a message using CDO 1.21. I have tried the method suggested on the Microsoft website as follows: VB.NET: Dim objAddress As MAPI.AddressEntry Dim address As String objAddress = objMessage.Sender ' this line gives error address = objAddress.Name MsgBox("The message address is: " & address) However it gives me a [MAPI_E_NOT_FOUND(8004010F)]] error, but I can access other properties of the message such as its text, date sent, size, subject etc. Cheers!
-
Has anyone come accross this ListView error before and know how to remedy it: A first chance exception of type 'System.Reflection.AmbiguousMatchException' occurred in microsoft.visualbasic.dll Additional information: No accessible overloaded 'ListViewSubItemCollection.Add' can be called without a narrowing conversion. (VB.NET) It seems to occur if I add a second subitem to my ListView. Its ok with 1 item and subitem.
-
Please help someone! I am trying to get a display of the emails in my Inbox in my application using a ListView. I can get the first item and subitem in my Loop cycling through the Inbox. However I cannot get any more subItems to print in the remaining collumns. If I do I get this error message: A first chance exception of type 'System.Reflection.AmbiguousMatchException' occurred in microsoft.visualbasic.dll Additional information: No accessible overloaded 'ListViewSubItemCollection.Add' can be called without a narrowing conversion. My code is as follows: VB.NET: Dim objMessage As MAPI.Message Dim lstStuff As New ListViewItem Dim count As Integer With ListView1.Items For Each objMessage In gobjSession.Inbox.Messages count = count + 1 lstStuff = .Add(objMessage.Size) With lstStuff .SubItems.Add(objMessage.Subject) .SubItems.Add(objMessage.TimeReceived) ' error if add this extra line End With Next End With End Sub Cheers!
-
Problem Solved! Well, in the end with some testing I managed to get this working. You need to rerun the Office XP setup and add the CDO 1.2.1 library as an extra install on Outlook as its not installed as default on the first install. Alas even after repointing the reference in VS.NET, it still would not work. Did not recognise the CDO.dll which came with Office XP as valid. Swapped it instead with a copy of the CDO.dll, which came with Outlook 98 and seemed to work fine.
-
Does any one know how to register dll's in Windows XP. I am not sure if this is possible, but I want to use the CDO 1.21 library (CDO.dll) to communicate with my copy of Outlook 2002. I have added it as a reference in my program but I am getting errors conserning CDO not being registered. As follows: A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in MIKEOPEMAIL.exe Additional information: COM object with CLSID {3FA7DEB3-6438-101B-ACC1-00AA00423326} is either not valid or not registered.
-
Changing/adding parameters seems to make no difference. It seems that you need to keep the file open, do all your editing, then close it. Doesn't like the file being constantly open and closed at run time it seems. Have learnt a lot so far and at least I have a solution. cheers for al the help everyone! For anyone interested, the solution I found was to add this command on the streamwriter on the exit button. Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click fileName.Close() ' close file fileName = Nothing End End Sub
-
I have debugged as suggested and the line causing the problem is : fileName.WriteLine(System.Environment.NewLine) The error is: A first chance exception of type 'System.NullReferenceException' occurred in WordMatcher.exe Additional information: Object reference not set to an instance of an object. If this line is commented out it gives the same error, but on the line below: fileName.WriteLine(strStore) Intead of closing the file after the word is added I have put it when the program is exited and it seems to have worked. Would like some explanation on the error, If possible!
-
I am using a file as a data store. It will allow me to write one word or sentance but if I try to write more than one it gives me my error opening file. Code is as follows: VB.NET: Dim strStore As String Dim fileName As New IO.StreamWriter(File.Open("C:\store.txt", IO.FileMode.Append)) ----------------------------------------------------------------------------------- Private Sub cmdStore_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStore.Click Try strStore = storeText.Text ' Text from text box fileName.WriteLine(System.Environment.NewLine) fileName.WriteLine(strStore) ' write to stream MsgBox(strStore & " has been stored!") ' message has stored fileName.Flush() ' flush to file fileName.Close() ' close file fileName = Nothing Catch ex As Exception MsgBox("Error Opening File!") 'error that is showing on second store attempt End Try End Sub Have a vague idea its something to do with opening and closing the file. Any ideas of the solution anyone!:confused: