tag:blogger.com,1999:blog-7176045.post-1107241210280879382005-02-01T09:56:00.000+03:002005-02-01T10:00:53.076+03:002005-02-01T10:00:53.076+03:00Code to send email from Outlook ExpressOriginally from <a href="http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=Xns9025E8880lylefairyahoocom@24.2.9.58&rnum=4">here</a>, just afraid that it can gone. Can run in Access also (of course):
<br />
<br /><span style="font-family:courier new;font-size:78%;">Type MAPIRecip
<br />Reserved As Long
<br />RecipClass As Long
<br />Name As String
<br />Address As String
<br />EIDSize As Long
<br />EntryID As String
<br />End Type
<br />
<br />
<br />Type MAPIFileTag
<br />Reserved As Long
<br />TagLength As Long
<br />Tag() As Byte
<br />EncodingLength As Long
<br />Encoding() As Byte
<br />End Type
<br />
<br />
<br />Type MAPIFile
<br />Reserved As Long
<br />Flags As Long
<br />Position As Long
<br />PathName As String
<br />FileName As String
<br />FileType As MAPIFileTag
<br />End Type
<br />
<br />
<br />Type MAPIMessage
<br />Reserved As Long
<br />Subject As String
<br />NoteText As String
<br />MessageType As String
<br />DateReceived As String
<br />ConversationID As String
<br />Originator As Long
<br />Flags As Long
<br />RecipCount As Long
<br />Recipients As Long
<br />Files As Long
<br />FileCount As Long
<br />End Type
<br />
<br />
<br />Declare Function MAPISendMail _
<br />Lib "c:\program files\outlook express\msoe.dll" ( _
<br />ByVal Session As Long, _
<br />ByVal UIParam As Long, _
<br />message As MAPIMessage, _
<br />ByVal Flags As Long, _
<br />ByVal Reserved As Long) As Long
<br />
<br />
<br />Sub SendMailWithOE(ByVal strSubject As String, ByVal strMess­age As String, ByRef
<br />aRecips As Variant)
<br />Dim recips() As MAPIRecip
<br />Dim message As MAPIMessage
<br />Dim z As Long
<br />ReDim recips(LBound(aRecips) To UBound(aRecips))
<br />For z = LBound(aRecips) To UBound(aRecips)
<br />With recips(z)
<br />.RecipClass = 1
<br />If InStr(aRecips(z), "@") <> 0 Then
<br />.Address = StrConv(aRecips(z), vbFromUnicode­)
<br />Else
<br />.Name = StrConv(aRecips(z), vbFromUnicode)
<br />End If
<br />End With
<br />Next z
<br />With message
<br />.NoteText = strMessage
<br />.Subject = strSubject
<br />.RecipCount = UBound(recips) - LBound(aRecips) + 1
<br />.Recipients = VarPtr(recips(LBound(recips)))
<br />End With
<br />MAPISendMail 0, 0, message, 0, 0
<br />End Sub
<br />
<br />
<br />Sub TestSendMailwithOE()
<br />Dim aRecips(0 To 0) As String
<br />aRecips(0) = "smtp:t...@syspac.com"
<br />SendMailWithOE "Send Mail Through OE", "Sure, you can, T­om!", aRecips
<br />End Sub
<br />
<br /></span>
<br />Alex Dybenkohttp://www.blogger.com/profile/16954512620659022712noreply@blogger.com2