sending a email via VB

How do I send out an email message in
VB code that by passes the usual user logins and pwd checks?

The Help file in MSDN Help illustrates an example of the Send method (CDONTS
objects).

I made a copy of it and tried to send
a short email to myself but to no avial.

There were no errors during compilation.

spidysengAsked:
Who is Participating?
 
MaximkaConnect With a Mentor Commented:
Private Type MAPIFILE_TYPE
    Reserved As Long
    flags As Long
    Position As Long
    PathName As String
    FileName As String
    FileType As String
End Type

Private Type MAPIMESSAGE_TYPE
    Reserved As Long
    Subject As String
    NoteText As String
    MessageType As String
    DateReceived As String
    ConversationID As String
    flags As Long
    RecipCount As Long
    FileCount As Long
End Type
Private Type MAPIRECIP_TYPE
    Reserved As Long
    RecipClass As Long
    Name As String
    Address As String
    EIDSize As Long
    EntryID As String
End Type
Private Declare Function MAPISendMail Lib "VBAMAP32.DLL" Alias "BMAPISendMail" (ByVal Session As Long, ByVal UIParam As Long, Message As MAPIMESSAGE_TYPE, Recipient As MAPIRECIP_TYPE, file As MAPIFILE_TYPE, ByVal flags As Long, ByVal Reserved As Long) As Long



private sub SenMyMess()
    Dim typMapiMsg As MAPIMESSAGE_TYPE
    Dim typMapiRecip As MAPIRECIP_TYPE
    Dim typMapiFile As MAPIFILE_TYPE
    Dim lSessionID As Long
    dim Result as long
   

        typMapiMsg.Subject = "My Subject"
        typMapiMsg.NoteText = "My note" & Time & Space(3) & Date
        typMapiMsg.MessageType = "IPM."         'MAPI_INTER_PERSONAL_MAIL_PREFIX
        typMapiMsg.RecipCount = 1               'one recipient
        typMapiMsg.FileCount = 0
        typMapiRecip.RecipClass = 1             'MAPI_TO
        typMapiRecip.Name = "maxim@ramdor.co.il"
        Result = MAPISendMail(lSessionID, 0, typMapiMsg, typMapiRecip, typMapiFile, 1, 0) 'MAPI_LOGON_UI
end sub
0
 
spidysengAuthor Commented:

Dear Maximka,

i tried to compile the code that you have shared and an error occurred with the function declaration line highlihted saying "Only comments are allowed after End Function, End Sub or
End Type.

Could you help please, thanks.







0
 
MaximkaCommented:
Please explane what happend .
If I interstand right You got Compile error
there are 2 options
or You did not copied right the code
(by the way the declaration has to be on one line )

or You don't have the VBAMAP32.DLL
0
 
spidysengAuthor Commented:
thanx man....
0
 
MaximkaCommented:
You wellcome !!!!
0
All Courses

From novice to tech pro — start learning today.