PDA

View Full Version : Very simple script... I think



wiseguy
10-23-2012, 02:55 PM
Hello, I'm looking for a very simple outlook macro but I have found very little information on the internet for copy pasting within the same email. Probably because it’s way to easy to do. Anyways was wondering if you could help me out with the big lines here. I will be able to modify the script once I see the commands I need written down. I just never programmed in my life, so take it easy on this first timer!
All I want is to copy the user name after User Name to replace the XX and the password after password to replace the XXX. I know it seems to be lazy of me to avoid two simple copy paste but it will save me some major time.
---------------
Thanks for using BOB’s FTP service.
As requested, an FTP site has been created at the following address:
ftp ://XX:XXX@ftp .bob. com

User Name :
Password :

The FTP site will be available until the 21 decembre 2012 (end of the world, eh!) . For any modifications please contact FTPcreation@bob.com.
* No backups are done of the FTP server. Keep a copy of your data to avoid any inconvenience.
Thanks and have a nice day,
Stuntman Mike
Bob FTP services
---------------

Thanks mates!

Charlize
10-31-2012, 04:40 AM
Sub FTP_Troubles()
'the mailmessage holder
Dim mymessage As Outlook.MailItem
'the text of the message, the altered text
Dim thebody As String, mytext As String
'thename = username of person, thepassword = password
Dim thename As String, thepassword As String
'*** Coding for getting info
'set the selected message to the active one
Set mymessage = ActiveExplorer.Selection.item(1)
'store the messagebody to the variable
thebody = mymessage.Body
'locate the start of the name in the message body and add 12 because
'we don't need the search string included
'then locate the end = vbcrlf, starting from the searchstring name and we are going to
'substract 12 + the number where we found vbcrlf to determine the name
thename = Mid(thebody, InStr(1, thebody, "User Name : ") + 12, _
InStr(InStr(1, thebody, "User Name : "), thebody, vbCrLf) - _
InStr(1, thebody, "User Name : ") - 12)
'here it's 11 because the length of the searchstring is 11
thepassword = Mid(thebody, InStr(1, thebody, "Password : ") + 11, _
InStr(InStr(1, thebody, "Password : "), thebody, vbCrLf) - _
InStr(1, thebody, "Password : ") - 11)
MsgBox thename & " - Password : " & thepassword
'replace XX: with thename & :
mytext = Replace(thebody, "XX:", thename & ":")
'replace XXX with thepassword
mytext = Replace(mytext, "XXX", thepassword)
'old messagebody is deleted and replaced by new one
mymessage.Body = mytext
'save the altered message
mymessage.Save
End SubCharlize