Results 1 to 3 of 3

Thread: Need help on sending email using mapi

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Need help on sending email using mapi

    Hi all,

    I use the following code to send an email from my application:
    vb Code:
    1. Public Function olk_SendMail(sTo As String, sSubject As String, sMessage As String, Optional ByVal blnSend As Boolean = True)
    2.     On Error GoTo Err_Trap
    3.     Dim objOutlook As Outlook.Application
    4.     Dim objMailItem As Outlook.MailItem
    5.     Set objOutlook = New Outlook.Application
    6.     Set objMailItem = objOutlook.CreateItem(olMailItem)
    7.  
    8.     With objMailItem
    9.         .To = sTo
    10.         .Subject = sSubject
    11.         .body = sMessage
    12.         If blnSend Then
    13.             .send
    14.         Else
    15.             .Save
    16.         End If
    17.     End With
    18.     Set objMailItem = Nothing
    19.     Set objOutlook = Nothing
    20.     Exit Function
    21.  
    22. Err_Trap:
    23.     Debug.Print Err.Number & " " & Err.Description
    24. End Function
    It works fine. I am executing this code from Excel. My problems are:

    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.
    Kanna

  2. #2

  3. #3
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Need help on sending email using mapi

    You can't. That is a security design because of SPAM. If you want to send email without that message you actually have to talk directly to the SMTP server and not thru Outlook AddIns and tools.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width