I have struggled to understand how to set my program to send email from a specified account in Outlook. I have multiple accounts and need to send email from a specific account so replies (if any are warranted) are sent back to the same account.
I have looked multiple places and either I am too dense to understand or I am completely missing the mark. The code below successfully opens Outlook populates the receiver's address, sets the subject and body fine. It just does not send via the proper account, always using the default email account, which forces me to adjust the sending account each time in Outlook an email is being sent. I just cannot figure out how to tell Outlook to use a specific eMail account.
Code:Private Sub RtbBillEmail_MouseDoubleClick(sender As Object, e As EventArgs) Handles tbBillEmail.MouseDoubleClick Cursor = Cursors.Hand Dim oOLook As Object Dim oEMail As Object Dim eMailSubject As String = "Load: " + tbBrokerLoadNumber.Text + " Inquiry" Dim eMailBody As String = "ENTER INQUIRY HERE" Dim eMailCC As String = "[email protected]" Dim eSender As String = "[email protected]" oOLook = CreateObject("Outlook.Application") oOLook.Session.Logon() oEMail = oOLook.CreateItem(0) oEMail.Display(False) With oEMail .Sender = eSender .To = tbAgentEmail.Text .CC = "" .BCC = eMailCC .Subject = eMailSubject .HTMLBody = eMailBody .ReadReceiptRequested = True 'Use the .Send() to auto Send the mail - not currently being used.' '.Send() End With Cursor = Cursors.Default End Sub




Reply With Quote
