|
I use this
Dim oMail As System.Net.Mail.MailMessage
Dim oFrom As System.Net.Mail.MailAddress
Dim oSmtp As System.Net.Mail.SmtpClient
oMail = New System.Net.Mail.MailMessage
oFrom = New System.Net.Mail.MailAddress("me@here.com")
oSmtp = New System.Net.Mail.SmtpClient("mail.here.com")
oMail.From = oFrom
oMail.To.Add("him@here.com, him@there.com, another@there.com)
oMail.Subject = "My Subject"
oMail.Priority = Net.Mail.MailPriority.Normal
oMail.IsBodyHtml = True
oMail.Body = "Body of rmail here"
oSmtp.Send(oMail)
|
|
|
|
|
Does this piece of code require you to setup an smtp server in IIS? If it does, then this piece of code will not work in my case. All I want to do is send an email with an attachment via outlook 2003 (connects to microsoft exchange) and the code needs to be compatible with vb2008.
My first post has working code (in vb2008) that can send email with outlook 2003, BUT without attachments!
|
|
|
|
|
I guess all you need to add is this line
<br />
.Attachments.Add("c:\myfolder\myfile.txt")
But this gives me security warning.
I will try to find how to avoid it.
Like car accidents, most hardware problems are due to driver error.
Samir R. Ibrahim
|
|
|
|
|
I have now switch to office 2007 and adding these lines worked perfectly:
' Add an attachment
Dim sSource As String = "C:\somefile.extension"
Dim sBodyLen As String = oMsg.Body.Length
Dim sDisplayName As String = ""
Dim oAttachs As Outlook.Attachments = oMsg.Attachments
Dim oAttach As Outlook.Attachment
oAttach = oAttachs.Add(sSource, , , sDisplayName)
oMsg.Send()
|
|
|
|
|
how to create round shapes??
could this work-
in a label(backcolor set equal to form's) set a round image.
won't this increase the cpu time??
i am looking for an efficient way to create a round shape
like in vb6 we'd just chose the shape control.
but in vb2008 all controls that don't have handles are dropped
is there a way to do so??
eh?
TheMrProgrammer
|
|
|
|
|
System.Drawing.Graphics provides the facility to create diffrent types of shape as you want.
Set your Backcolor as forms color or set it to transparent.
If you can think then I Can.
|
|
|
|
|
Or you can Google for the "VB.NET Power Packs". The 3.0 version has shape controls in it like those that used to be in VB6.
|
|
|
|
|
hi
modified 28-Nov-12 8:23am.
|
|
|
|
|
|
Using cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB\E_Ensemb.mdb")
check this
remove only the ; from the end
|
|
|
|
|
I need to directly connect to the .dbf files and not with the .mdb files...
|
|
|
|
|
.dbf is DBase file which belong to VFP (Visual Foxpro)
I use this to connect
Dim _cnn As New OleDb.OleDbConnection("Provider=VFPOLEDB.1;Data Source=F:\myfolder\myfile.dbf")
If you don't have VFPOLEDB in your ODBC, install the driver from here
Microsoft OLE DB Provider for Visual FoxPro 9.0[^]
Like car accidents, most hardware problems are due to driver error.
Samir R. Ibrahim
|
|
|
|
|
|
Thanks to all who replied.
The links really helped.
|
|
|
|
|
The value of w doesnt increase or decrease once it reaches the value 2 .. can someone please tell me why..
Thanks in advance
<br />
Public Class Form1<br />
Dim g As Graphics<br />
Dim db As Boolean<br />
Dim x As Integer = 100<br />
Dim y As Integer = 100<br />
Dim w As Integer = 150<br />
Dim h As Integer = 150<br />
<br />
<br />
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel<br />
Console.WriteLine(e.Delta.ToString)<br />
If (e.Delta > 0) Then<br />
Console.WriteLine("in zoomin")<br />
w = w * (e.Delta / 100)<br />
Console.WriteLine("inside zoomin e.delta " & e.Delta.ToString)<br />
Console.WriteLine("w" & w)<br />
h = h * (e.Delta / 100)<br />
End If<br />
If (e.Delta < 0) Then<br />
Console.WriteLine("zoomout")<br />
w = w / ((e.Delta * -1) / 100)<br />
h = h / ((e.Delta * -1 / 100))<br />
<br />
End If<br />
Console.WriteLine("w" & w)<br />
Me.Refresh()<br />
End Sub<br />
<br />
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint<br />
<br />
e.Graphics.DrawRectangle(Pens.Black, x, y, w, h)<br />
End Sub<br />
<br />
End Class<br />
<br />
|
|
|
|
|
I suspect the answer is that even if VB doesn't round e.Delta/100 to an int, once it rounds the end result to an int, it's going to not be big enough to get past 2 in either direction. Do e.Delta / 100.0 to make it work with a float, and consider what you do when the end result moves the value by less than .5, which means it will round back to what it was. Perhaps you need to store w as a float, and make it an int only when you're using it to draw with.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Public Class Form1
Dim g As Graphics
Dim db As Boolean
Dim x As Integer = 100
Dim y As Integer = 100
Dim w As Integer = 150
Dim h As Integer = 150
Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
Console.WriteLine(e.Delta.ToString)
If (e.Delta > 0) Then
Console.WriteLine("in zoomin")
w = IIf((w * (e.Delta / 100)) < 3, 3, (w * (e.Delta / 100)))
'w = w * (e.Delta / 100)
Console.WriteLine("inside zoomin e.delta " & e.Delta.ToString)
Console.WriteLine("w" & w)
h = IIf((h * (e.Delta / 100)) < 3, 3, (h * (e.Delta / 100)))
'h = h * (e.Delta / 100)
End If
If (e.Delta < 0) Then
Console.WriteLine("zoomout")
w = w / ((e.Delta * -1) / 100)
h = h / ((e.Delta * -1 / 100))
End If
Console.WriteLine("w" & w)
Me.Refresh()
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.DrawRectangle(Pens.Black, x, y, w, h)
End Sub
End Class
dinvit83
|
|
|
|
|
Not very efficient, but it works. I prefer to lead people to water, rather than throw water at them.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
Christian Graus wrote: lead people to water, rather than throw water at them
Remind me never to spontaneously combust around you!!
|
|
|
|
|
Previously my code was working perfectly fine but suddenly showing up this error Unable to write data to the transport connection:An existing connection was forcibly closed by the remote host; whenever i try to write something on the network stream. Following is the code i am using right now:
Dim PacketSize As Integer = 8192
Dim client As New TcpClient
client.Connect(IPAddress.Parse("192.168.15.51"), 7771)
Dim ns As NetworkStream = client.GetStream
Dim fs As New FileStream(FileName, FileMode.Open, FileAccess.Read)
Dim buffer(PacketSize - 1) As Byte
Dim i As Integer
i = fs.Read(buffer, 0, PacketSize)
While i <> 0
ns.Write(buffer, 0, i) <-- this line cause the error
i = fs.Read(buffer, 0, PacketSize)
End While
fs.Close()
ns.Close()
There's no anti-virus or firewall on target machine. I've even turned window's firewall off. Do i have to start any service on the target machine which somehow stopped??? I've searched everywhere but didn't find solution. Please help.
AliAmjad(MCP)
First make it Run THEN make it Run Fast!
modified on Tuesday, May 5, 2009 2:13 AM
|
|
|
|
|
http://social.msdn.microsoft.com/forums/en-US/netfxnetcom/thread/6981b252-30f0-4eb9-a3a6-bf6f2b138fb3/
Visit this.
dinvit83
|
|
|
|
|
I got exactly the same problem. this app used to works well....
|
|
|
|
|
Hi,
I've written the below code (using Visual Basic 2008 Express) to maximize a notepad window, close the notepad window and then restart the notepad window. During the debugging (F5), everything works fine.
Then i build the project. However, when i run the .exe file (in Release folder), the notepad window stops at ALT+TAB and did not maximize and close and then a new notepad application window is started. It is not working exactly the same as what i saw during debugging.
Can anyone pls advice me what went wrong? Thanks very much.
================================================================================================
Imports System.Runtime.InteropServices
Imports System.Threading
Module Module1
<DllImport("user32.dll")> Public Function _
FindWindow(ByVal strClassName As String, ByVal strWindowName As String) As Integer
End Function
<DllImport("User32.DLL")> Public Function _
SetForegroundWindow(ByVal Hwnd As Long) As Boolean
End Function
Sub Main()
Dim hwnd As Long
Dim ProcID As Integer
hwnd = FindWindow(vbNullString, "Untitled - Notepad")
If hwnd <> 0 Then
'MsgBox("The window handle is " & hwnd)
SetForegroundWindow(hwnd)
'Restore minimized Notepad window
Thread.Sleep(3000)
My.Computer.Keyboard.SendKeys("%( )X", True) 'ALT+SPACEBAR to restore minimize window
'Close Notepad
Thread.Sleep(3000)
My.Computer.Keyboard.SendKeys("%{F}X", True) 'ALT+F in Notepad
'Start Notepad after 10 seconds delay
Thread.Sleep(10000) 'Delay 10000 milliseconds
ProcID = Shell("NOTEPAD.EXE", AppWinStyle.NormalFocus) 'Start Notepad.exe
AppActivate(ProcID)
Else
GoTo Finish
'MsgBox("Notepad is not running")
End If
Finish:
End Sub
End Module
======================================================================================================
|
|
|
|
|
helen00 wrote: My.Computer.Keyboard.SendKeys("%( )X", True) 'ALT+SPACEBAR to restore minimize window
I'd avoid using SendKeys altogether. It's a bad method for controlling another application since the input focus can change to any window at ANY time. This includes the time between your call to SetForegroundWindow and the call to SendKeys.
Alt-Space, X closes the current window. It does not "restore minimize window".
helen00 wrote: the notepad window stops at ALT+TAB
Your code doesn't mention anything about Alt-Tab.
Your should be using .NET classes and methods to do this. The Process class makes it a lot easier and you don't have to PInvoke any Win32 functions to do it.
|
|
|
|
|
Hi,
Thanks for your prompt reply.
Can you advise me sample codes of the better way to control another application? My whole objective of writing the program is to look for the Notepad window, graceful close the notepad via File > Exit and then restart the Notepad.
Your help and guidance will be greatly appreciate.
Regards
|
|
|
|