Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Problem with Mail code

Im having a problem trying to figure out why one email function works but
another one doesnt. Both codes work on my home computer using Outlook, but
when I try to run them at work(we use Lotus Notes) the Sub
Mail_Text_in_Body_3() code does not create the message. It seems like it is
calling up Lotus Notes but the email message doesnt get created. I have
changed the mail server to Lotus Notes in Internet Explorer.
The code Mail_ActiveSheet() works fine


Private Declare Function ShellExecute Lib "Shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As
String, _
ByVal nShowCmd As Long) As Long
__________________________________________________ ______________________
Sub Mail_Text_in_Body_3()
'Creates statement for a person and emails it to data entry
Dim msg As String, URL As String
Dim Recipient As String, Subj As String
Dim cell As Range
Recipient = "data"

Subj = "Statement for " & Sheets("Employee List").Range("Q1").Value & "
for Incident " & Sheets("Employee List").Range("N7").Value

msg = "Statement of " & Sheets("Employee List").Range("Q1").Value & " of
My Work" & vbNewLine & vbNewLine
For Each cell In Sheets("Employee List").Range("N3")
msg = msg & vbNewLine & cell
Next cell
msg = WorksheetFunction.Substitute(msg, vbNewLine, "%0D%0A")

msg = WorksheetFunction.Substitute(msg, vbLf, "%0D%0A")
URL = "mailto:" & Recipient & "&subject=" & Subj & "&body=" & msg
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString,
vbNormalFocus
Application.Wait (Now + TimeValue("0:00:08"))
Application.SendKeys "%s"
End Sub




Sub Mail_ActiveSheet()
Dim strdate As String
Dim FName1, FName2, Fullname
FName1 = Range("AU2").Value & "-"
FName2 = Range("J4").Value
Fullname = FName1 & FName2
ActiveSheet.Copy
strdate = Format(Date, "dd-mm-yy") & " " & Format(Time, "h-mm-ss")
ActiveSheet.SaveAs "Sheet1 " & Fullname _
& " " & strdate & ".xls"
ActiveWorkbook.SendMail "data", _
Fullname
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.Fullname
ActiveWorkbook.Close False
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
First zero doesn't show up in zip code mail merge. DLencz Excel Worksheet Functions 1 November 12th 07 08:30 PM
zip code with mail merge Booklisa Excel Discussion (Misc queries) 4 August 30th 07 05:24 PM
Code launches Mail Merge but disables the Mail Merge austris Excel Discussion (Misc queries) 0 October 14th 06 01:11 AM
Sending E-Mail by code ASU Excel Discussion (Misc queries) 2 June 13th 06 01:17 PM
E-mail Code Zan Excel Programming 5 August 12th 04 11:30 PM


All times are GMT +1. The time now is 02:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"