Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Outlook Opening Multiple Message Windows

$
0
0

The code below works rather well and enables me to open an Outlook email message and to transfer To, Subject and Msg from my VB.net application.
The problem is that it opens two e-mail messages? Is there a reason it does that and or a way to only open only one message window?

Thank you for any assistance!

Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'******************** Add E-Mail Function FROM Here ******************
Dim SendToEmail As String
SendToEmail = Request.QueryString.Item("Email")

Dim Subject As String
Dim Recipient As String
Dim Message As String
Subject = "Testing Request Confirmation"
Recipient = SendToEmail & ""
'Recipient = "'" & SendToEmail & "'"
Message = "Thanks for providig your contact information"
SendOutlookMail(Subject, Recipient, Message)
End Sub

Public Sub SendOutlookMail(Subject As String, Recipient As _
String, Message As String)

On Error GoTo errorHandler
Dim oLapp As Object
oLapp = CreateObject("Outlook.Application")
'Outlook.Application()
Dim oItem As Object

'oLapp = CreateObject("Outlook.application")
oItem = oLapp.CreateItem(0)

With oItem
.Subject = Subject
.To = Recipient
.body = Message
.Display()
'.Send()
End With

oLapp = Nothing
oItem = Nothing


Exit Sub

errorHandler:
oLapp = Nothing
oItem = Nothing
Exit Sub


End Sub


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>