L
Lori
I have a custom page in Outlook 2003 that is created for a contact
item. Developed with VS.NET 1.1.
I have a problem saving values to my controls. The first time the page
is created, I am able to load a picture to my image control based on
the value of my text box. Everything works just fine.
The problems occurs when I update the information. When I'm re-open the
contact, I am able to change the image source and text. I can click on
general tab, details tab, back to test tab and everythings is okay.
However, when I close the contact item and open it up again, I get the
original information which I had saved and not the updated informaton.
I've include some of my code. Is it necessary to use User-defined
fields? Information is saved the firsttime around but not the second.
Code that creates the custom form
Private Sub CreateTestTab()
Try
myPages = m_olContactItem.GetInspector.ModifiedFormPages
myPage = myPages.Add("Test")
ctrls = myPage.Controls
'Create TextBox Control
If (ctrls.Count < 0) Then
txtMapSource = ctrls.Add("Forms.TextBox.1", "txtMapSource",
True)
imgTest = ctrls.Add("Forms.Image.1", "imgTest", True)
btnGetMap = ctrls.Add("Forms.CommandButton.1", "btnGetMap")
End If
txtMapSource.Visible = True
txtMapSource.Height = 24
txtMapSource.Width = 350
txtMapSource.Left = 120
txtMapSource.Top = 32
imgTest.Height = 300
imgTest.Width = 300
imgTest.Left = 16
imgTest.Top = 88
imgTest.Visible = True
btnGetMap.Caption = "Get Test map"
btnGetMap.Visible = True
btnGetMap.Height = 24
btnGetMap.Width = 96
btnGetMap.Left = 16
btnGetMap.Top = 32
Catch ex As Exception
MsgBox("Error: " + ex.Message)
Finally
DisposeObject(myPages)
DisposeObject(myPage)
DisposeObject(myPagesCheck)
DisposeObject(ctrls)
DisposeObject(oWeb)
DisposeObject(txtMapSource)
End Try
End Sub
Code to update control values:
Private Sub btnGetMap_Click() Handles btnGetMap.Click
Dim imageNet As System.Drawing.Image
Dim ctrls As MSForms.Controls 'Controls collection
Dim txtMapSource As MSForms.Control
Dim httpStream As Stream
Dim httpWReq As HttpWebRequest
Dim httpWResp As HttpWebResponse
Try
txtMapSource =
m_olContactItem.GetInspector.ModifiedFormPages("Test").Controls("txtMapSource")
imgTest =
m_olContactItem.GetInspector.ModifiedFormPages("Test").Controls("imgTest")
If (txtMapSource.Text <> "") Then
httpWReq = CType(WebRequest.Create(txtMapSource.Text),
HttpWebRequest)
httpWResp = CType(httpWReq.GetResponse(), HttpWebResponse)
imageNet =
System.Drawing.Image.FromStream(httpWResp.GetResponseStream())
imgTest.Picture = Compatibility.VB6.ImageToIPicture(imageNet)
End If
m_olContactItem.Save()
Catch ex As Exception
MsgBox("Error button popup : " + ex.Message)
Finally
End Try
End Sub
Thanks in advance for your help.
item. Developed with VS.NET 1.1.
I have a problem saving values to my controls. The first time the page
is created, I am able to load a picture to my image control based on
the value of my text box. Everything works just fine.
The problems occurs when I update the information. When I'm re-open the
contact, I am able to change the image source and text. I can click on
general tab, details tab, back to test tab and everythings is okay.
However, when I close the contact item and open it up again, I get the
original information which I had saved and not the updated informaton.
I've include some of my code. Is it necessary to use User-defined
fields? Information is saved the firsttime around but not the second.
Code that creates the custom form
Private Sub CreateTestTab()
Try
myPages = m_olContactItem.GetInspector.ModifiedFormPages
myPage = myPages.Add("Test")
ctrls = myPage.Controls
'Create TextBox Control
If (ctrls.Count < 0) Then
txtMapSource = ctrls.Add("Forms.TextBox.1", "txtMapSource",
True)
imgTest = ctrls.Add("Forms.Image.1", "imgTest", True)
btnGetMap = ctrls.Add("Forms.CommandButton.1", "btnGetMap")
End If
txtMapSource.Visible = True
txtMapSource.Height = 24
txtMapSource.Width = 350
txtMapSource.Left = 120
txtMapSource.Top = 32
imgTest.Height = 300
imgTest.Width = 300
imgTest.Left = 16
imgTest.Top = 88
imgTest.Visible = True
btnGetMap.Caption = "Get Test map"
btnGetMap.Visible = True
btnGetMap.Height = 24
btnGetMap.Width = 96
btnGetMap.Left = 16
btnGetMap.Top = 32
Catch ex As Exception
MsgBox("Error: " + ex.Message)
Finally
DisposeObject(myPages)
DisposeObject(myPage)
DisposeObject(myPagesCheck)
DisposeObject(ctrls)
DisposeObject(oWeb)
DisposeObject(txtMapSource)
End Try
End Sub
Code to update control values:
Private Sub btnGetMap_Click() Handles btnGetMap.Click
Dim imageNet As System.Drawing.Image
Dim ctrls As MSForms.Controls 'Controls collection
Dim txtMapSource As MSForms.Control
Dim httpStream As Stream
Dim httpWReq As HttpWebRequest
Dim httpWResp As HttpWebResponse
Try
txtMapSource =
m_olContactItem.GetInspector.ModifiedFormPages("Test").Controls("txtMapSource")
imgTest =
m_olContactItem.GetInspector.ModifiedFormPages("Test").Controls("imgTest")
If (txtMapSource.Text <> "") Then
httpWReq = CType(WebRequest.Create(txtMapSource.Text),
HttpWebRequest)
httpWResp = CType(httpWReq.GetResponse(), HttpWebResponse)
imageNet =
System.Drawing.Image.FromStream(httpWResp.GetResponseStream())
imgTest.Picture = Compatibility.VB6.ImageToIPicture(imageNet)
End If
m_olContactItem.Save()
Catch ex As Exception
MsgBox("Error button popup : " + ex.Message)
Finally
End Try
End Sub
Thanks in advance for your help.