Connecting Tech Pros Worldwide Help | Site Map

How to send email without displaying it ...

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 03:00 PM
Ronny Sigo
Guest
 
Posts: n/a
Default How to send email without displaying it ...

Hello all,
Can anyone tell me how to prevent my mailprog to display the mail, and just
send it ?
The code I use is below
Any help appreciated ..
Thanks
Ronny Sigo

Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
As String, ByVal lpFile As String, ByVal lpParameters _
As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Private Const SW_SHOW = 5

Public Function OpenEmail(EmailAddress As String, _
Optional Subject As String, Optional Body As String) _
As Boolean

Dim lWindow As Long
Dim lRet As Long
Dim sParams As String

sParams = EmailAddress
If LCase(Left(sParams, 7)) <> "mailto:" Then _
sParams = "mailto:" & sParams

If Subject <> "" Then sParams = sParams & "?subject=" & Subject

If Body <> "" Then
sParams = sParams & IIf(Subject = "", "?", "&")
sParams = sParams & "body=" & Body
End If

lRet = ShellExecute(lWindow, "open", sParams, _
vbNullString, vbNullString, SW_SHOW)

OpenEmail = lRet = 0

End Function




  #2  
Old November 12th, 2005, 03:00 PM
Ruskin Hardie
Guest
 
Posts: n/a
Default Re: How to send email without displaying it ...

If you are using outlook (version 98 or higher), then this will work fine;

Sub SendMessage(myRecipient As String, _
mySubject As String, _
Optional myBody As String, _
Optional myFileName As String)

On Error Resume Next

Dim myObject As Object
Dim myItem As Object

Set myObject = CreateObject("Outlook.Application")
Set myItem = myObject.CreateItem(0)

With myItem
.Subject = mySubject
.To = myRecipient
If Trim(myBody) <> "" Then
.Body = myBody
End If
If Trim(myFileName) <> "" Then
If Dir(myFileName) <> "" Then
.Attachments.Add (myFileName)
End If
End If
.Send
End With

Set myItem = Nothing
Set myObject = Nothing
End Sub


"Ronny Sigo" <ronny.sigo@example.invalid> wrote in message
news:3fa54623$0$22171$ba620e4c@reader3.news.skynet .be...[color=blue]
> Hello all,
> Can anyone tell me how to prevent my mailprog to display the mail, and[/color]
just[color=blue]
> send it ?
> The code I use is below
> Any help appreciated ..
> Thanks
> Ronny Sigo
>
> Private Declare Function ShellExecute Lib "shell32.dll" Alias _
> "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
> As String, ByVal lpFile As String, ByVal lpParameters _
> As String, ByVal lpDirectory As String, _
> ByVal nShowCmd As Long) As Long
> Private Const SW_SHOW = 5
>
> Public Function OpenEmail(EmailAddress As String, _
> Optional Subject As String, Optional Body As String) _
> As Boolean
>
> Dim lWindow As Long
> Dim lRet As Long
> Dim sParams As String
>
> sParams = EmailAddress
> If LCase(Left(sParams, 7)) <> "mailto:" Then _
> sParams = "mailto:" & sParams
>
> If Subject <> "" Then sParams = sParams & "?subject=" & Subject
>
> If Body <> "" Then
> sParams = sParams & IIf(Subject = "", "?", "&")
> sParams = sParams & "body=" & Body
> End If
>
> lRet = ShellExecute(lWindow, "open", sParams, _
> vbNullString, vbNullString, SW_SHOW)
>
> OpenEmail = lRet = 0
>
> End Function
>
>
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.