473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

send an e-mail with vbs

1
hello all,

although i'm not familiar with vbs, i was asked to create a script which will do the following:

1. change the extension of a document to .txt,
2. open the file,
3. read the lines and find an e-mail address,
4. create a new e-mail with Notes and attach the file,
5. send it to the e-mail address.


how much of these can be done with vbs? how can it be done?

I'd really appreciate your help..
thanks in advance!

gulsh
Feb 1 '07 #1
2 2125
willakawill
1,646 1GB
Hi the first thing to do is take a look at filesystemobject
Then look for lotus notes automation
Feb 3 '07 #2
Hi there

Try this out !

Put Your mail adresses in a file called 'maillist', and place it in C:\

The file could look like this:

john@doe.com
jane@doe.com



Then open an empty vbs-file, then copy and paste the lines below ino the file:

Expand|Select|Wrap|Line Numbers
  1.  'Script start
  2. Set notessession = CreateObject("Notes.Notessession") 
  3. Set notesdb = notessession.GetDatabase("", "") 
  4. Call notesdb.OPENMAIL 
  5.  
  6. set fso = WScript.CreateObject("Scripting.FileSystemObject") 
  7.  
  8. ' path1 is Your input file and path2 is the name with the txt extension 
  9.  
  10.   path1 = "C:\maillist" 
  11.   path2 = "C:\maillist.txt" 
  12.  
  13. ' copy the file 
  14.          fso.CopyFile path1 , path2, true 
  15.          WScript.Sleep 1000 
  16.  
  17. ' delete Your input file 
  18.          fso.DeleteFile path1 
  19.  
  20. ' get and open Your mail-address file 
  21. Set ifile = fso.GetFile("c:\maillist.txt") 
  22. Set infil = ifile.OpenAsTextStream 
  23.  
  24. Do until eof 
  25. ' read a line/mail-address from the file 
  26.         mailadr = infil.readline 
  27.  
  28. ' if nothing is read, then its EOF, so leave the loop 
  29.         If mailadr = "" then 
  30.                 exit do 
  31.         End if 
  32.  
  33. 'MsgBox (mailadr) 
  34.  
  35. 'Make new mail message 
  36. Set notesdoc = notesdb.CreateDocument 
  37. notesdoc.Form = "Memo" 
  38.  
  39. ' Set up the recipients 
  40. Call notesdoc.ReplaceItemValue("Sendto", mailadr) 
  41. 'Call notesdoc.ReplaceItemValue("CopyTo", mailadr) 
  42. 'Call notesdoc.ReplaceItemValue("BlindCopyTo", mailadr) 
  43.  
  44. 'The subject of the mail 
  45. subj = "TEST MAIL  " & mailadr 
  46.  
  47.  
  48. ' setup three text blocks - note that we use VBCRLF to make the carrige return, line feed 
  49. mailtxt = "Test mail" 
  50.  
  51. mailtxt1 = "Hello" & reg 
  52.  
  53. mailtxt2 = "Here is Your mail" 
  54. mailtxt2 = mailtxt2 &  VBCRLF 
  55. mailtxt2 = mailtxt2 &  "Below You will fin a link to google"  & VBCRLF 
  56. mailtxt2 = mailtxt2 &  VBCRLF 
  57. mailtxt2 = mailtxt2 &  "Link:" & VBCRLF 
  58. mailtxt2 = mailtxt2 & "http://www.google.com"  & VBCRLF 
  59. mailtxt2 = mailtxt2 &  ""  & VBCRLF 
  60. mailtxt2 = mailtxt2 &  ""  & VBCRLF 
  61. mailtxt2 = mailtxt2 &  "Regards"  & VBCRLF 
  62. mailtxt2 = mailtxt2 &  "John Doe"  & VBCRLF 
  63.  
  64. Call notesdoc.ReplaceItemValue("Subject", subj) 
  65. Set notesrtf = notesdoc.CreateRichTextItem("body") 
  66.  
  67. 'put the three text blocks in the body of the mail - note that we use AddNewLine to make som space between the blocks 
  68. Call notesrtf.AppendText(mailtxt) 
  69. Call notesrtf.AddNewLine(2) 
  70.  
  71. Call notesrtf.AppendText(mailtxt1) 
  72. Call notesrtf.AddNewLine(2) 
  73.  
  74. Call notesrtf.AppendText(mailtxt2) 
  75. Call notesrtf.AddNewLine(2) 
  76.  
  77. notesdoc.SaveMessageOnSend = 1 
  78.  
  79. '  You can also attach a file 
  80.     Call notesrtf.EmbedObject(1454, "", "C:\maillist.txt") 
  81.  
  82. 'Send message 
  83. notesdoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder 
  84. Call notesdoc.Send(False) 
  85.  
  86. loop 
  87.  
  88. Set fso = Nothing 
  89. Set notessession = Nothing 
  90. MsgBox ("Mail send")
  91. 'Script End
Feb 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Tom Brown | last post by:
Hi, I have what seems to be a simple problem. But I can not for the life of me find a way to send an integer over a socket. The send method will only accept strings. Here is what I am trying to...
9
by: Etienne Charland | last post by:
Hi, there is an application running on a remote desktop (under Citrix ICA, but the same problem applies for RDC or PC Anywhere). Now, I want to send keys to the remote application from a local app....
5
by: Pete Loveall | last post by:
I have a server application that monitors a private local queue for messages. The message sent to it has a label and a response queue defined. It works correctly when the queue is accessed via...
1
by: Kitchen Bin | last post by:
Hi. I am trying to use Sockets to do multiple Send and Receives via HTTP (not simultaneously). A first pair of Send/Receives works fine and sure enough I receive HTML back, but the next...
0
by: zhimin | last post by:
Hi, I'm writing a program to send large file(100m) through dotnet using TCPListener & TCPClient, I'm sending the file with a ask and response loop: 1. Client send a flag 1 to server indicate it...
1
by: GrantS | last post by:
I need to use a sendkeys key combination to automate the "accept files" that a remote user wants to send to me via Windows messenger. I am using automation to work with Windows Messenger client in...
3
by: Sara | last post by:
HI, I want to code a program to detect GSM mobile (any kind) which connected through serial port to computer and then be able to send SMS through this mobile phone to other mobile phones, could...
1
by: Hasan O | last post by:
hi , I have a problem with socket.send mesajlar = Encoding.ASCII.GetBytes("UGIR"); socketResultValue = socket.Send(mesajlar,0,mesajlar.Length, SocketFlags.None); socketResultValue =...
3
by: ultr | last post by:
Hello, I have read that send() may not send whole message and returns the nuber of bytes sent, so that we can handle the rest of the message. Is it true, because i have tested sending even 1MB...
0
by: Xionbox | last post by:
Hello everybody, The error I have seems very easy to solve, but for some odd reason I can't seem to solve it. Anyways, here's my "setup". I created a server running on localhost:1200 (telnet...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.