Dim tempNS As Outlook.NameSpace
Dim MailFolder As Outlook.MAPIFolder
tempNS = tempApp.GetNamespace("MAPI")
tempNS.Logon(, , True, True)
Dim newMail As Outlook.MailItem
MailFolder = tempNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderOutbox)
newMail = MailFolder.Items.Add(Outlook.OlItemType.olMailItem)
' sent email will be saved in your outbox also
newMail.Subject = String.Format("Reference No#:" & " " & txt_generate.Text & " " & "||" & " " & "Requestor Name:" & " " & txt_name.Text & " " & "||" & " " & "Priority:" & " " & txt_priority.Text)
newMail.Body = String.Format("Request/Issue:" & " " & cmb_issue1.Text & " " & vbNewLine & vbNewLine & "Issue/Request Details:" & vbNewLine & txt_request.Text & vbNewLine & vbNewLine & "Sender Email:" & " " & txtFrom.Text)
newMail.To = txtTo.Text
newMail.SaveSentMessageFolder = MailFolder
' Add an attachment
' TODO: Replace with a valid attachment path.
Dim sSource As String = "HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\12.0\Outlook\Security"
' TODO: Replace with attachment name
Dim sBodyLen As String = newMail.Body.Length
Dim oAttachs As Outlook.Attachments = newMail.Attachments
newMail.Send()
' reply to sender
Dim newMail2 As Outlook.MailItem
newMail2 = MailFolder.Items.Add(Outlook.OlItemType.olMailItem)
newMail2.Subject = String.Format("Reference No#:" & " " & txt_generate.Text & " " & "||" & " " & "Requestor Name:" & " " & txt_name.Text)
newMail2.Body = txt_reply.Text
newMail2.To = txtFrom.Text
newMail2.SaveSentMessageFolder = MailFolder
newMail2.Send()
MsgBox("E-mail has been sent")
OSCris.Show()
Me.Close()
End Sub
0