Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Attachment 1

Status
Not open for further replies.

clayton74

Technical User
Apr 17, 2002
187
GB
Hello All

I have a little program that will email a user once a new XP account has been created. I have a problem with the attachment, this is dependent on the creator having a drive mapped for them to email the attachment. My question is there a way of embedding a word document into my project so I do not have to ensure the creator has a drive mapped.
Any help would be appreciated

Private Sub cmdxpgenmail_Click()
Dim oOutlook As Object
Dim oItem As Object
Dim xp1a, xp1, xp2, xp3, xp4, xp5, xp6, xp7, xp8
Dim sAttachment As String


sAttachment = "G:\IT HELPDESK\rats\RATS mailer\newstarter2007.doc" ' Sets location of Attachment
Set oOutlook = CreateObject("Outlook.Application")
Set oItem = oOutlook.CreateItem(0)
With oItem

xp1a = "Dear"
xp1 = "In response to your request for the creation of a basic XP Account, on call reference " & txtxpref
xp2 = "this has now been created with Userid: " & txtxpuser & " and a temporary Password of " & txtxppass & ", this grants access to the Network Rail Network, and the associated MS Outlook Account."
xp3 = "A Portal account has also been created with Userid " & txtxpportuser & " and a temporary password of " & txtxpportpass & "."
xp4 = "Please reply to this email with the voting buttons to confirm user has successfully logged in."
xp5 = "Regards "
xp6 = "IT Helpdesk "
xp7 = "Requests and Technical Specialists "

' Email Values
.Subject = "New XP Account (Call Ref: " & txtxpref.Text & ")" ' Value of the mail subject
.To = txtxpto.Text 'Value i the mail to box
.Body = xp1a & vbCrLf & "" & vbCrLf & xp1 & vbCrLf & xp2 & vbCrLf & xp3 & vbCrLf & xp4 & vbCrLf & " " & vbCrLf & xp5 & vbCrLf & " " & vbCrLf & xp6 & vbCrLf & xp7 & vbCrLf & xp8 'Body of E-mail 'Body of E-mail
'.Attachments.Add sattach
.VotingOptions = "Yes;No" 'Displays voting buttons on mail
oItem.Display 'display the message before sending.
.Attachments.Add sAttachment ' Adds attachment
 

I am just guessing here, but is your G:\ drive a server?
If so, usually it is not really a G:\ drive, but something like \\ntsvr5 (if it is a server 5), so you can do that:

sAttachment = "\\ntsvr5\IT HELPDESK\rats\RATS mailer\newstarter2007.doc"

which is a lot better pointer to that drive.

BTW, why do you declare several Variants if you need just strings:
Dim xp1a, xp1, xp2, xp3, xp4, xp5, xp6, xp7, xp8

You could do:
Dim strBody As String

strBody = "Dear" & vbNewLine
strBody = strBody & ""In response to your ... " & vbNewLine
...
.Body = strBody



Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top