Hi all,
I use the following code to send an email from my application:It works fine. I am executing this code from Excel. My problems are:vb Code:
Public Function olk_SendMail(sTo As String, sSubject As String, sMessage As String, Optional ByVal blnSend As Boolean = True) On Error GoTo Err_Trap Dim objOutlook As Outlook.Application Dim objMailItem As Outlook.MailItem Set objOutlook = New Outlook.Application Set objMailItem = objOutlook.CreateItem(olMailItem) With objMailItem .To = sTo .Subject = sSubject .body = sMessage If blnSend Then .send Else .Save End If End With Set objMailItem = Nothing Set objOutlook = Nothing Exit Function Err_Trap: Debug.Print Err.Number & " " & Err.Description End Function
1. The code prompts/warns the user that,
"A program is trying to automatically send e-mail on your behalf. Do you want to allow this?"
If the user clicks "Yes" then the mail sent successfully. No issues.
How to send mail without confirmation?
2. It sends the mail using Outlook with its default account. I mean, I have configured two email accounts in my outlook. One is default.
How can I send email using outlook from the email account which is not default?
Thanks in advance.




Reply With Quote