Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending e-mail within vbasic6

Status
Not open for further replies.

tamer

Programmer
Apr 28, 1999
2
0
0
TR
I am trying to make a program which uses outlook express or exchance and send mail but I have to use my vb text box and I dont wanna user to be able to see the message but they have to know what are thet doing so please help me to write mail sending program THANKs Tamer
 
There is a sample that comes with VB called VBmail (Project name is Prjmapi.vbp)<br>
Its in 'Misc' folder under the samples<br>
Take a look at it<br>
<br>

 
Declare Function ShellExecute Lib &quot;shell32.dll&quot; Alias &quot;ShellExecuteA&quot; _<br>
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _<br>
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long<br>
<br>
Function ShellToBrowser%(Frm As Form, ByVal URL$, ByVal WindowStyle%)<br>
Dim api%<br>
api% = ShellExecute(Frm.hwnd, &quot;open&quot;, URL$, &quot;&quot;, App.path, WindowStyle%)<br>
'Check return value<br>
If api% &lt; 31 Then<br>
'error code - see api help for more info<br>
MsgBox App.Title & &quot; had a problem running your web browser.You should check that your browser is correctly installed.(Error&quot; & Format$(api%) & &quot;)&quot;, 48, &quot;Browser Unavailable&quot;<br>
ShellToBrowser% = False<br>
Else<br>
If api% = 32 Then<br>
'no file association<br>
MsgBox App.Title & &quot; could not find a file association for URL$ &&quot; _<br>
& &quot; on your system. You should check that your browser is correctly installed and associated with this type of file.&quot;, 48, _<br>
&quot;Browser Unavailable&quot;<br>
ShellToBrowser% = False<br>
Else 'It worked!<br>
ShellToBrowser% = True<br>
End If<br>
End If<br>
End Function<br>
<br>
Private Sub cmdEmail_Click()<br>
Dim success As Integer<br>
Dim site As String<br>
If Trim(email_adres.Text) = &quot;&quot; Then<br>
MsgBox &quot;U heeft géén email adres opgegeven&quot;, vbCritical, &quot;&quot;<br>
Else<br>
site = &quot;mailto:&quot; & Trim(email_adres.Text)<br>
End If<br>
success% = ShellToBrowser(Me, site, 0)<br>
<br>
End Sub<br>
<br>
Eric De Decker
 
Eric when I use your example I get an error<br>
<br>
Run Time error '53': &quot;File not found&quot; <br>
<br>
on the Shell statement.<br>
<br>
Is there something missing I am using NT workstation?
 
File not found"<br>
<br>
EmailAdres is a TextBox with e-mailadres or declare<br>
<br>
Dim EmailAdres As String<br>
<br>
EmailAdres = "vbg.be@vbgroup.nl"<br>
<br>
RetVal = Shell("start mailto:" & EmailAdres, 0)<br>
<br>
<br>
<br>
<br>

 
No file not found means the Shell statement cannot launch a program called &quot;start mailto:&quot;<br>
see <br>
start mailto:<A HREF="mailto:dposton@uiversal1.com">dposton@uiversal1.com</A><br>
<br>
My compuyter does not recognise &quot;Start&quot; as some program to run like Calculator.exe or Winword.exe.<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Works on Win98 with VB6 and Outlook Express or Outlook (NT have a mailserver on the network?)<br>
<br>
Eric<br>

 
Yes, here's is my stuff<br>
VB6<br>
NT workstation 4.0 service pack 4<br>
Outlook '98 connected to Exchange Server 5.5 service pack 2<br>
also outlook connected to &quot;Intel E-mail station&quot; for outside e-mial.<br>
I suspect NT being older than '98 does not recognize &quot;Start&quot;<br>
I'll try this on a '98 box here.<br>
<br>
Now I use the following all the time in Access '97<br>
<br>
DoCmd.SendObject acSendNoObject, &quot;&quot;, acFormatTXT, Email, , , &quot;Order Confirmation&quot;, EmailInfo, False<br>
<br>
and it works fine.<br>
I just though of something would'nt be nice if we wrote a &quot;docmd&quot; function for VB.<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Late as this comment is, using ShellExecute API call with operation &quot;open&quot; and file set to &quot;mailto:fred@bigsite.com&quot; does the trick in terms of firing default mail client.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top