Sunday, 15 September 2013

vb.net - Email Terminal Shortcut -



vb.net - Email Terminal Shortcut -

i need alter vba code class. i'm looking @ tutorial http://spreadsheetpage.com/index.php/tip/sending_personalized_email_from_excel/ , instead of outlook, want utilize apple mail service stmp["mailto:"] functions straight excel. have subject , message portion down, want know if can run script straight terminal if save properly? , can annotate need create specific changes pertaining email.

private declare function shellexecute lib "shell32.dll" _ alias "shellexecutea" (byval hwnd long, byval lpoperation string, _ byval lpfile string, byval lpparameters string, byval lpdirectory string, _ byval nshowcmd long) long sub sendemail() dim email string, subj string dim msg string, url string dim r integer, x double r = 2 4 'data in rows 2-4 ' email address email = cells(r, 2) ' message subject subj = "your annual bonus" ' compose message msg = "" msg = msg & "dear " & cells(r, 1) & "," & vbcrlf & vbcrlf msg = msg & "i pleased inform annual bonus " msg = msg & cells(r, 3).text & "." & vbcrlf & vbcrlf msg = msg & "william rose" & vbcrlf msg = msg & "president" ' replace spaces %20 (hex) subj = application.worksheetfunction.substitute(subj, " ", "%20") msg = application.worksheetfunction.substitute(msg, " ", "%20") ' replace carriage returns %0d%0a (hex) msg = application.worksheetfunction.substitute(msg, vbcrlf, "%0d%0a") ' create url url = "mailto:" & email & "?subject=" & subj & "&body=" & msg ' execute url (start email client) shellexecute 0&, vbnullstring, url, vbnullstring, vbnullstring, vbnormalfocus ' wait 2 seconds before sending keystrokes application.wait (now + timevalue("0:00:02")) application.sendkeys "%s" next r end sub

in windows, can save vba application .vbs file , run command prompt or windows explorer. there might errors, if have excel specific functions, or if vb versions aren't same, in general run.

vb.net excel vba

No comments:

Post a Comment