How to use API to send and receive emails, how to use API to perform Base64 codec

zhaozj2021-02-17  61

Minfo.dll is a dynamic connection library I made by I did, and is currently a beta version. You can download from http://xlrj.com/am/am/am. The following is the contents of readme.txt:

This is the test version, please put Minfo.dll into the system directory (for example: c: / windows / system) minfo.dll includes the following API: Public Declare Function Logon LIB "Minfo.dll" (Popinfo As Popinfo, Byval Er As String ) AS long login POP3 server, if successful, you should use logoff to exit. Public Declare Function DeleteMail Lib "minfo.dll" (ByVal nIndex As Long, ByVal er As String) As Long removes the specified message Public Declare Function GetMailInfo Lib "minfo.dll" (mount As Long, minfo As Long, ByVal er As String AS Long get mail information, including email, email header, sender, mail length, mail date public declare function getmaildata lib "minfo.dll" (Byval FileName As String, BYVAL ER AS String) AS LONG gets the specified message content and stores file public declare sub logoff lib "minfo.dll" () exits POP3 mail server public declare function encode lib "minfo.dll" (Data as LONG, RTNLONG AS Long AS Long Base64 encoded byte array PUBLIC DECLARE FUNCTION DECODE LIB "minfo.dll" (DATA AS BYTE, L AS LONG) AS Long Base64 Decoded byte Array PUBLIC DECLARE FUNCTION Sendmail LIB "Minfo.dll" (SMTPIN As SMTPINFO, MAILDATA AS BYTE, BYVAL SUBJECT AS STRING, BYVAL ATACHMENT AS STRING, BYVAL ER AS STRING AS Long Send Mail

Test.xls provides some examples of using these APIs. The following is the VBA code of the file:

Type popinfouser As String 'username pass As String' password popsvr As String 'Incoming Mail Server End TypeType mailinfofrom As Long' sender subject As Long 'Message Subject date As Long' mailing date mlen As Long 'message length End TypeType smtpinfo smtpsvr AS String 'SMTP Server Sender AS String' Sender Receiver AS String 'Recipient, Multiple Recipients, Separate Auth As Long' Need 0 No 0 No User As String 'User Name Pass AS String 'password End TypePublic Declare Sub Logoff Lib "minfo.dll" () Public Declare Function Logon Lib "minfo.dll" (popinfo As popinfo, ByVal er As String) As LongPublic Declare Function DeleteMail Lib "minfo.dll" (ByVal nIndex As Long, ByVal er As String) As LongPublic Declare Function SendMail Lib "minfo.dll" (smtpin As smtpinfo, maildata As Byte, ByVal subject As String, ByVal attachment As String, ByVal er As String) As Long 'send mail Public Declare Function GetmailInfo LIB "Minfo.dll" (Mount As Long, Minfo As Long, Byval Er AS String) AS Long 'Get Mail Information Public Declare Function Encode lib "minfo.dll" (Data as Byte, Byval L as long "base64 encoded public declare function decode lib" minfo.dll "(Data as a") as long 'base64 decoding Public Declare Function GetMailData Lib "minfo.dll" (ByVal nIndex As Long, ByVal filename As String, ByVal er As String) As Long 'get the message content Public Declare Sub CopyMemory Lib "kernel32" Alias ​​"RtlMoveMemory" (Destination As Any, Source As Any, BYVAL Length As Long Public Declare Function Shellexecute Lib "shell32.dll" Alias ​​"shellexecutea"

(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongSub EncodeIt () Dim hh () As Byte 'before encoding byte array hh = StrConv ("In order to provide you in advance, your software works can now be automatically added through our system.", Vbfromunicode) 'encoded byte arrays DIM LL AS long' encoding byte array address DIM RLONG AS LONG 'encoding length ll = encode (hh (0), ubound (hh) 1, rlong)' Ubound (HH) 1 is to decode byte array length DIM LLL () AS BYTEREDIM LLL (rlong - 1) CopyMemory LLL (0), ByVal LL, Rlongdim LLLL AS STRINGLLLLLLLLL = STRCONV (LLL, VBUNICODE) MSGBOX LLLLEND SUB

Sub DecodeIt () length Dim Dim gg () As Byte 'to be decoded byte array Dim bb As Long' Long 'decoded byte array address decoded byte array Dim m As ff As Stringff = "PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv" ff = ff & vbCrLf & "PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv" ff = ff & vbCrLf & "dD0idGV4dC9odG1sOyBjaGFyc2V0PWdiMjMxMiI DQo8TUVUQSBjb250ZW50PSJNU0hUTUwgNi4w" ff = ff & vbCrLf & "MC4yNzE1LjQwMCIgbmFtZT1HRU5FUkFUT1I DQo8U1RZTEU PC9TVFlMRT4NCjwvSEVBRD4NCjxC" ff = ff & vbCrLf & "T0RZIGJnQ29sb3I9I2ZmZmZmZj4NCjxESVY PEZPTlQgc2l6ZT0yPsTjw8e1xMjtvP7K1NPDyrHD" ff = ff & vbCrLf & "3MLryuTKssO0PC9GT05UPjwvRElWPjwvQk9EWT48L0hUTUw DQO = "gg = strconv (ff, vbfromunicode) bb = decode (GG (0), M) DIM CC () AS BYTEREDIM CC (M - 1) CopyMemory CC (0), ByVal BB, MDIM DD AS STRINGDDD = STRCONV ( CC, vbunicode) msgbox ddend subs getmail () on error goto bbbdim info1 as popinfoinfo1.user = "whypop3" 'User name info1.pass = "whypop3")' password info1.popsvr = "pop.163.com" 'POP3 Post Part Server DIM INFO2 () as mailinfo 'will be returned as mail information will be returned to DIM S as string' error information DIM RC As long '1, represents success, 0, failed DIM C As long "DIM TEMP AS long" mail information address Dim n as longs = string (255, chr (0)) RC = Logon (info1, s) if rc = 0 ThenMSGBOX Sexit Subend IFRC = GetmailInfo (C, Temp, s) if rc = 0 ThenMSGBOX SELSEIF C = 0 ThenMSGBOX " You have no new email "Elseredim Info2 (C - 1) CopyMemory Info2 (0), ByVal Temp, Len (Info2) * CVV =" You have "& C &" Block "for i =

0 To c - 1Dim from As StringDim subject As StringDim dat As StringDim lenth As LongCopyMemory from, info2 (i) .from, 4CopyMemory subject, info2 (i) .subject, 4CopyMemory dat, info2 (i) .date, 4CopyMemory lenth, info2 (i) .mlen, 4VV = VV & VBCRLF & VBCRLF & "Sender:" & Left (from, INSTR (from, chr (0)) - 1) VV = VV & "&" topic: "& left (Subject, INSTR (Subject, Chr (0)) - 1) VV = VV & "&" "& LentHVV = VV &" & "Send Date:" & Left (DAT, INSTR (DAT, CHR (0)) - 1) Nextmsgbox VVS = String (255, chr (0)) DIM L1 As longl1 = getmAildata (1, "e: /TEMP.EML", S) '1 mail serial number, "E: / TEMP. EML "Store IF L1 = 0 THENMSGBOX SGOTO BBBBEND IFSHELLEXECUTE 0," Open "," E: /TEMP.EML "," "", SW_SHOWNORMALDETEMAIL 1, S '1 Mail Sequence MsgBox Send Ifbbbbbbbbbbbb: Logofend Subsub Sendemail () DIM SMTPIN AS SMTPINFODIM S AS STRINGS = String (255, chr (0)) SMTPIN.SENDER = "whypop3@163.com" smtpin.receiver = "whypop3@163.com" smtpin.smtpsvr = "SMTP.163. Com "smtpin.auth = 1smtpin.user =" whypop3 "smtpin.pass =" whypop3 "DIM GG AS STRINGGGGGGG = VBCRLF & VBCRLF &" Hello ! Everybody !!! "Dim Dby () AS BYTEDBY = STRCONV (GG, VBFROMUNICODE) DIM RC AS Longrc = Sendmail (SMTPIN, DBY (0)," Test Program "," E: /TEMP.EML "& CHR (34 ) & "E: /TEMP.EXE", s) 'Several parameters are SMTPINFO structure, mail content bytes, theme, accessory name (with "separated multiple attachments), error information if rc = 1 ThenMSGBOX" Sent successfully! "Elsemsgbox" sent failed! "& vbcrlf & send ifend sub

The beta is free, I hope friends can give constructive advice. For friends who gave me during the test, I will increase the official version in the future. The official version will include: 1.minfo.dll2. Detailed and complete help documentation 3. Description of the prototype 4. You may include an ActiveX control to encapsulate these APIs to facilitate usage in scripting languages. Emmel web software design studio qaymuic@163.com

* Asked friends, is it supported by MIME, multiple accessories, and more, as follows:

For received messages, just the original post-emission acquisition of mail data, do not do any processing, what is handled, and the process should be handed over to the user (programmer).

For the sent mail, it is organized according to the email rules, as long as you don't add two or three hundred attachments, huh, huh. There is no problem with an attachment within 200. The transmission speed is also much faster than OE. Regarding MIME, in order to be safe, the sender is basically not processed, left to the client software processing, if it is OE, there is no problem with HTML, but will reject attempts to run the attachment program in HTML.

转载请注明原文地址:https://www.9cbs.com/read-30801.html

New Post(0)