function mailto(theAddress, theSubject, theBody) % mailto -- Compose e-mail in browser. % mailto('address', 'subject', 'body') invokes % the "mailto" facility of the local web-browser, % using the given address, subject-line, and % a short body, if any. If the body is surrounded % by double-quotes, it will be treated as the name % of a file to be inserted as the body. % % Note: use "%" with hexadecimal-code for non- % printing characters, such as "%0D" for char(13) % carriage- return. %% % Macintosh: maximum URL length is 255 characters. % Copyright (C) 2001 Dr. Charles R. Denham, ZYDECO. % All Rights Reserved. % Disclosure without explicit written consent from the % copyright owner does not constitute publication. % Version of 25-Sep-2001 16:54:54. % Updated 18-Oct-2001 14:54:13. MACINTOSH_URL_MAX_LEN = 255; % Maximum. theURL = 'mailto:'; if nargin > 0 if ~any(theAddress == '@') theAddress = [theAddress '@usgs.gov']; end theURL = [theURL theAddress]; end if nargin > 1, theURL = [theURL '?subject=' theSubject]; end if nargin > 2 if theBody(1) == '"' & theBody(end) == '"' filename = theBody(2:end-1); fp = fopen(which(filename), 'r'); theBody = char(fread(fp).'); fclose(fp); end theBody = strrep(theBody, char(10), '%0A'); % Line-feed. theBody = strrep(theBody, char(13), '%0D'); % Carriage-return. theBody = strrep(theBody, char(32), '%20'); % Blank. theURL = [theURL '&body=' theBody]; end c = computer; if any(findstr(c, 'MAC2')) if length(theURL) > MACINTOSH_URL_MAX_LEN theURL = theURL(1:MACINTOSH_URL_MAX_LEN); end end web(theURL);