Poniżej najprostszy kod VBA w Access do wysyłania mailingu. Za jego pomocą wyślemy maila poprzez swoje główne konto pocztowe. Konto pocztowe musi być wcześniej prawidłowo skonfigurowane:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | Sub MailByAccess() PID = Shell("outlook.exe", vbNormalFocus) 'tym kodem uruchamiamy Outlooka Dim omsoutlook As Object Dim oemail As Object Dim blnRet As Boolean Set omsoutlook = CreateObject("Outlook.Application") Set oemail = omsoutlook.createitem(olmailitem) With oemail .To = "tomasz.kenig@xxx.pl" 'wpisujemy odbiorcę .subject = "Temat" ' wpisujemy temat emaila .body = "Tresc E-maila" 'wpisujemy treść emaila .send End With Set omsoutlook = Nothing Set oemail = Nothing 'PID = Shell("D:\refresh_outlook.cmd", vbNormalFocus) End Sub |